The number of simultaneous connections to the server is controlled by both the WCF service throttling mode and your machine (this is the OS, really). Windows XP machines had a hard limit of 10 concurrent connections - maybe a problem? If you are running a server, this restriction should not apply.
service throttling behavior also has a default value of MaxConcurrentSessions , which is 10, and your netTcpBinding connections will have a session transport layer, so there is definitely a problem too.
You can change the settings of the service throttling behavior in the application configuration file:
<serviceBehaviors> <behavior name="TcpMoreThan10"> <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="50" maxConcurrentInstances="50" /> </behavior> </serviceBehaviors>
and you will need to add this service behavior to the <service> , of course, to enable it:
<service name="....." behaviorConfiguration="TcpMoreThan10"> .... </service>
If you only have up to 50 clients calling sporadically, and they are all "internal" clients using netTcpBinding, I see no good reason why you want to make this thing multi-threaded singleton, really.
As a side note: multi-threaded singletones are not so difficult to write, it is difficult to get everything right, you need to worry about concurrent access to your internal variables, etc. - pretty dirty programming.
Why not use the default instance mode for each call? Wherein:
- each request that is part of its own, separate, isolated, just created instance of a service class
- each instance of the service class only processes exactly one caller, so there is no need for messy and complex multi-threaded programming models.
source share