1
votes

I am trying to plugin a custom message encoder into the WCF pipeline through configuration. Earlier I was using the out of box "NetTcpBinding" for which my configuration file looked like

<bindings>
      <netTcpBinding>
         <binding name="DefaultNetTcpBinding"
                 maxBufferSize="26214400"
                 maxReceivedMessageSize="26214400"
                 maxBufferPoolSize="26214400"
                 listenBacklog="1000"
                 maxConnections="1000"
                 closeTimeout="00:01:00"
                 openTimeout="00:10:00"
                 receiveTimeout="00:01:30"
                 sendTimeout="00:01:00">
          <security mode="None"/>
          <reliableSession ordered="true" inactivityTimeout="00:01:30" enabled="true"/>
        </binding>
      </netTcpBinding>
</bindings>

For plugging in the custom encoder I tried to following custom binding configuration

<bindings>
      <customBinding>
          <binding name="compactBinding">
              <compactMessageEncoding>
                          <binaryMessageEncoding/>
              </compactMessageEncoding>
              <tcpTransport />
          </binding>
      </customBinding>
  </bindings>

It works fine. But I still want my earlier settings like maxBufferSize, maxReceivedMessageSize, maxBufferPoolSize etc. It seems the <binding> element under <customBinding> only has closeTimeout, openTimeout, receiveTimeout, sendTimeout.

How to pass on the other information?

Thanks

3

3 Answers

8
votes

Try adding a HttpTransportBindingElement. I think that will do the trick for you. Here is the link.

1
votes
<customBinding>
      <binding>
       ...
        <tcpTransport listenBacklog ="100" maxBufferPoolSize ="524288" maxBufferSize ="2147483647" maxReceivedMessageSize ="2147483647"/>
       ...
      </binding>
</customBinding>
1
votes

Try adding the configuration in code like this:

((CustomBinding)servicio.Endpoint.Binding).Elements.Find<TransportBindingElement>().MaxReceivedMessageSize = int.MaxValue;

And also add a readerQuotas to the web.config:

<readerQuotas maxDepth="90000" maxStringContentLength="2147483647"
                         maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />