Search code examples
wcfwcf-binding

AddressAlreadyInUseException when using customBinding but not when using netTcpBinding


I know that the leasTimeout settings are part of the connectionPoolSettings element. I know that connectionPoolSettings is a child of tcpTransport. It looks like this can be configured only as a customBinding and not a netTcpBinding

When I switch from netTcpBinding to customBinding, I get error messages about "There is already a listener on IP endpoint 0.0.0.0:8091. Make sure that you are not trying to use this endpoint multiple times in your application and that there are no other applications listening on this endpoint."

No changes have been made to the port specifications.

Here is my netTcpBinding configuration:

  <netTcpBinding>
    <binding name="TcpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxConnections="10" maxReceivedMessageSize="100000000">
      <readerQuotas maxNameTableCharCount="1000000" maxStringContentLength="8192000" maxArrayLength="1638400" />
      <security mode="None">
      </security>
    </binding>
</netTcpBinding>

Here is my customBinding:

<customBinding>
    <binding name="TcpBindingCustom">
      <windowsStreamSecurity ProtectionLevel="None" />
      <tcpTransport>
        <connectionPoolSettings GroupName="default" leaseTimeout="00:05:00"
            idleTimeout="00:02:00" MaxOutboundConnectionsPerEndpoint="20" />
      </tcpTransport>
    </binding>
  </customBinding>

I do not get this error message when using netTcpBinding only when using the customBinding.

I have also determined that I do not get this error message if I comment out the mex endpoint, but that does not solve the problem but maybe it will help us find a solution.


Solution

  • Not an anwser to the question but a comment that might save you in the future when you app is holding onto a huge amount of memeory. You have set maxBufferPoolSize to 524288 and maxReceivedMessageSize to 100000000 (752MBs) which potential means (depending on how you have you app pool setup) that you could have 524288 cached buffers each with a size of 100000000 (752MB)! We recently had a problem with our service (running on iis7) holding on to 1GB of memory. This was due to the setting maxBufferPoolSize which specifys the max number of buffers that can be cached. With a number as high a 524288 you are setting yourself up for trouble. We have set this to a lower number but you need to think a balance as it will affect the speed. In any case I would not set it past a few with a maxReceivedMessageSize that large! (does it need to be that large?) - anyway just a tip to save you days of memory profiling and head scratching!