I'm working with two applications, one has a self hosted service configured to use the net.tcp binding. The ServiceBehaviorAttribute of the service is configured with:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple,
InstanceContextMode = InstanceContextMode.Single,
IncludeExceptionDetailInFaults = true,
UseSynchronizationContext = false,
ValidateMustUnderstand = false)]
For both, service and client the transferMode is set to Streamed, and the timeouts are:
closeTimeout="00:01:00"
openTimeout="00:00:30"
receiveTimeout="00:02:30"
sendTimeout="00:02:30"
MaxConnections is set to 500 and the ServiceThrottlingBehavior uses the WCF 4 default values:
I'm using a quad-core machine and the Net.Tcp Port Sharing service is enabled.
The client application has a single channel to the service created using the ChannelFactory class. Once the channel is created 100 threads are spawned. Each thread uses the channel to send messages to the server with a frequency of one message per second.
After a couple of seconds running ok (the client sends messages to the server an it receives them correctly) an EndpointNotFoundException is thrown with the following message:
Could not connect to net.tcp://localhost/service. The connection attempt lasted
for a time span of 00:00:02.1777100. TCP error code 10061: No connection could
be made because the target machine actively refused it 127.0.0.1:808.
The weird things are:
I made a lot of tests, reducing the amount of threads, increasing it, changing the close, open, receive and send timeouts to lower and higher values, setting a higher value for maxConnections but the result is always the same, at some point the EndpointNotFoundException is thrown. I'm about to give up and change the code so each thread has its own channel hoping this fixes the issue, but I want to know why this happens. If someone knows what I'm doing wrong or can point me in the right direction to keep investigating it will be helpful.
By default Windows doesn't enable port sharing. I would check that you have it properly enabled (see here).
If possible, you could also try changing the port of one application, or do testing of one within a VM.
Also, for anyone else that may have the same issue, do as Diego has done and check that port sharing is enabled in the configuration. Add portSharingEnabled="true"
to the binding:
<system.serviceModel>
<bindings>
<netTcpBinding name="portSharingBinding"
portSharingEnabled="true" />
<services>
<service name="MyService">
<endpoint address="net.tcp://localhost/MyService"
binding="netTcpBinding"
contract="IMyService"
bindingConfiguration="portSharingBinding" />
</service>
</services>
</system.serviceModel>
Taken from: http://msdn.microsoft.com/en-us/library/ms731810.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With