Question

Is there a way to see whether WCF MaxConcurrentSessions or MaxConcurrentCalls has been reached?

We have a WCF service with a number of operations. Most are request/response, but one is a long-polling method, which returns after a long time unless something happens server side.

It is used to send notifications in near real-time from the WCF service to the clients. If nothing happens, the method returns after a while with a timeout message, and the client will call it again to poll for new notifications.

The service is running as InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple.

Single Instance is due to the real-time notifications - they are received from another system via UDP, and the WCF service binds to a local UDP port so it can listen for the notifications, and pass them on to the waiting clients.

We have detected that the default settings for MaxConcurrentSessions and MaxConcurrentCalls are too low for the number of active clients using the service. They seem to block a session or call for each of the long-polling requests, which mean that the request/response requests are blocked until their turn.

We would like to keep using the long-polling pattern - two-way bindings or direct TCP are out of the question due to firewall traversal issues. We can of course just increase the MaxConcurrentSessions and MaxConcurrentCalls values to MAXINT or similar, but I am not a fan of this approach. Instead, I would like to increase the values to something sane, and be able to detect whether the ceiling has been reached.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top