I work with two applications, I have a self-service service configured to use the net.tcp binding. Service ServiceBehaviorAttribute is configured using:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true, UseSynchronizationContext = false, ValidateMustUnderstand = false)]
For both services and the client, the transferMode parameter is set to Streamed, and timeouts are:
closeTimeout="00:01:00" openTimeout="00:00:30" receiveTimeout="00:02:30" sendTimeout="00:02:30"
MaxConnections is set to 500, and ServiceThrottlingBehavior uses the default values ββfor WCF 4:
- MaxConcurrentSessions: 100 * ProcessorCount
- MaxConcurrentCalls: 16 * ProcessorCount
- MaxConcurrentInstances: The default value is the sum of the two above, which follows the same pattern as before.
I am using a quad-core machine and the Net.Tcp port exchange service is enabled.
The client application has one channel for a service created using the ChannelFactory class. After creating the channel, 100 threads are generated. Each thread uses a channel to send messages to the server at a frequency of one message per second.
After several seconds of operation (the client sends messages to the server and receives them correctly), an EndpointNotFoundException is thrown with the following message:
Could not connect to net.tcp:
Weird things:
- If I run both applications on one computer, the exception time interval is about 2 seconds, but if I run the server application on my computer and the client application on another machine, the exception time interval is always 1 second.
- Several times (for example, every tenth), an exception is not thrown, and both applications work fine.
- Before an exception is thrown, the server receives messages and processes them correctly. Exceptions are not thrown on the server.
I have done many tests, reducing the number of threads, increasing them, changing the timeouts for closing, opening, receiving and sending to lower and higher values, setting a higher value for maxConnections, but the result is always the same, at some point an EndpointNotFoundException is thrown. I am going to drop and modify the code so that each thread has its own channel, hoping this fixes the problem, but I want to know why this is happening. If someone knows what I'm doing wrong, or can point me in the right direction to continue the investigation, this will be helpful.