views:

26

answers:

1

Is it possible to check the number of existing available connections a wcf service has? programmatically?

I want to see if connections to the web service were closed properly in the ASP.NET code. thanks

+2  A: 

You could check out something like Windows Server AppFabric for that purpose.

In WCF, most of the time, the "connections" are only open very briefly anyway - for as long as a service call lasts. So you can't really go check if there are any connections around - they'll be gone when the call terminates.

You can also check into the WCF performance counters that are available on the server side to keep an eye on the number of concurrent sessions. You can definitely query performance counters from .NET code. The Service Performance Counters offer e.g. a number of instances (of your service class) that are in memory at any given time - that's the number of requests being handled at any given time (which is probably what you could call a "connection" to a WCF service).

marc_s
+1 for the performance counters part. Those can be inspected by perfmon as well as queried from code.
500 - Internal Server Error
Note that number of instances does not necessarily equal the number of requests. The InstanceContextMode setting can throw that off. See here: http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx
mwilson
I knew about the performance counter but wasn't aware that it can actually tell you the number of instances. Thanks!
fishiefishie
@mwilson: true - but it's probably the closest to the "number of connections" you can get using perf counters
marc_s