2

I'm running into a weird issue with my WCF Service using WS binding. When I configure it with no sessions (security/reliable) it works just fine, but not so with sessions. For example when I configure with security (message security, windows credentials), I get a timeout after 10th or 11th call. My service calls another WCF Service but, but both services are configured with same binding parameters.

How would you debug an issue like this? What tools would you use other than turning on tracing and using SvcTraceViewer?

aogan
  • 2,241
  • 1
  • 15
  • 24

4 Answers4

3

One of the easiest areas to lose lots of time on while developing WCF services is in binding configuration. Backup your working configs religiously, for starters, in the source code repository. You may also want to add a validation routine for config file itself that runs prior to service creation.

As far as debugging such WCF issues, there really is no substitute for the good old Trace.WriteLine() that write to a TraceListener that is mapped to a file, on the service and in the client. But really, considering your issue is rather common and is most likely 100% config-related, I would suggest learning more about the binding settings, particularly timeouts. Set values to arbitrarily high numbers or even to the Timeout.Infinite numeric value (as a string), which will literally tell WCF to allow for an infinite timeout. Then, ask yourself, why something would be timing out that does not do so with just a slight change in the binding.

Regarding you specific issue, it is possible that sessions are not being terminated properly because client proxies are not being closed properly by calling the Close() method explicitly. You might be able to get away with this when you are dealing with sessionless bindings, but sessions will not be released unless you close the proxy. The side effect of this would be that the default service throttling values of usually 10 concurrent sessions will be reached. Once you understand the life cycle of a session, you might want to look into the IsInitiating, IsTerminating and IsOneWay properties that can be specified for OperationContract attributes on the methods of the service contract.

Here are a few useful resources:

OperationContract: (strange url that won't link)
http://en.csharp-online.net/WCF_Services—OperationContract_Attribute

Using Sessions:
http://msdn.microsoft.com/en-us/library/ms733040.aspx

A Handy Summary of WCF sessions, instancing, and reliable messaging
http://www.pluralsight.com/community/blogs/aaron/archive/2006/02/27/19253.aspx

And, as mentioned by Brian, my response to a throttling question:
WCF Service Throttling

Community
  • 1
  • 1
  • Closing of session is the first area I looked since I'm aware of the session throttling settings which is mention above. Also, I agree most of the issues turn out to be configuration related. – aogan Feb 14 '09 at 11:37
  • So, have you ruled out session problems? What makes you believe it is not related? Has increasing the throttling settings allowed for more connections? – EnocNRoll - AnandaGopal Pardue Feb 14 '09 at 14:21
1

The best way to debug such scenario would be to activate tracing in the WCF service/client. The tracer creates log files which you can use the build-in trace viewer to read. http://msdn.microsoft.com/en-us/library/ms733025.aspx

dotmad
  • 174
  • 1
  • I'm awaretracing (see last paragrpah). My question was is there anything else. – aogan Feb 13 '09 at 17:27
  • Sorry, missed your comment. But why would you need another way? – dotmad Feb 13 '09 at 18:12
  • I was just wondering whether there is something else out there. Also I found that tracing is not that easy to use, especially when there are protocol (security,reliable messaging) messages are involved. – aogan Feb 13 '09 at 20:22
  • I agree that it is a pain to use the SvcTraceViewer and for some strange reason I thought the original implementation of the utility was better than it is today. – EnocNRoll - AnandaGopal Pardue Feb 14 '09 at 07:45
0

Sounds like you may be hitting a throttle...

WCF Service Throttling

http://kennyw.com/indigo/150

Community
  • 1
  • 1
Brian
  • 117,631
  • 17
  • 236
  • 300
0

Don't forget to call the .Close() method on the proxy from your client.

Maxim
  • 7,268
  • 1
  • 32
  • 44