Home > database >  increase message size in wcf-wpf service?
increase message size in wcf-wpf service?

Time:03-05

i have a wpf app and want to send byte[] to my wcf(plus wpf) using NetTcpBinding but have

QuotaExceededException: The maximum message size quota for the remote channel has been exceeded. For more information, see the server logs

I saw "MaxBufferSize" and "maxReceivedMessageSize" in the document, but it doesn't help.

service app.config

<bindings>
    <netTcpBinding>
      <binding name="NetTcpBinding_IService"
               maxBufferSize="20971520"
               maxBufferPoolSize="20971520"
               maxReceivedMessageSize="20971520"
             >
        <readerQuotas maxDepth="32" 
             maxArrayLength="20971520"/>
      </binding>
    </netTcpBinding>
  </bindings>

and my client, the full configuration generated automatically from service ref, except binding attribute

<bindings>
  <netTcpBinding>
      <binding name="NetTcpBinding_IService"
               maxBufferSize="20971520"
               maxBufferPoolSize="20971520"
               maxReceivedMessageSize="20971520"
             >
        <readerQuotas maxDepth="32" 
             maxArrayLength="20971520"/>
      <security>
        <transport sslProtocols="None" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

i also try get logs(on client side)

 <system.diagnostics>
    <sources>
        <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
            <listeners>
                <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                    <filter type="" />
                </add>
                <add name="ServiceModelMessageLoggingListener">
                    <filter type="" />
                </add>
            </listeners>
        </source>
        <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
            <listeners>
                <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                    <filter type="" />
                </add>
                <add name="ServiceModelTraceListener">
                    <filter type="" />
                </add>
            </listeners>
        </source>
    </sources>
    <sharedListeners>
        <add initializeData="L:\Projects\Service\Client\Client\App_messages.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
        </add>
        <add initializeData="L:\Projects\Service\Client\Client\App_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
        </add>
    </sharedListeners>
    <trace autoflush="true" />
</system.diagnostics>

but it just doesn't work! it doesn't even generate a .svclog file. i've seen a lot of topics here about this problem, but I couldn't find anything that could help me. the only hope is for the local overmind

CodePudding user response:

in <endpoint> on service side you should add bindingConfiguration="myBind" to you binding like

<binding name="NetTcpBinding_IService" 
             transferMode="Buffered"
             maxBufferPoolSize="20971520" 
             maxBufferSize="20971520" 
             maxReceivedMessageSize="20971520"/>
<services>
      <service name="name">
        <endpoint bindingConfiguration="NetTcpBinding_IService" 
              address="you address" 
              binding="netTcpBinding" contract="you contract"/>
      </service>
</services>
  • Related