Hello, I have a scenario where, upon receiving a command on one of the callback methods in client, the client needs to call another service. For example: In OnNewCommand() callback method client receives a message X. Now the client must call Service1() defined in the server. Note, Client has registered to the callback of Service1(). I can not use the same client object to call Service1() since it results in dead-lock. So I use a new client object to call Service1(). But it hangs until timeout period expires. Any idea how to fix it? Thanks
Off the top of my head, a couple of things to check for:
- If you're using HTTP, increase the number of HTTP connections allowed from the client side to the HTTP server. This is 2 by default and might not be enough for your needs.
- Make sure the throttling options in your WCF service are enough to handle all your required connections.
You may be getting a deadlock...
If possible define your callback methods to be “OneWay” and/or make a none blocking call to them, e.g. “begin_m1(...)”
Also check what the ConcurrencyMode you are using on the client and the server and see if you can use ConcurrencyMode.Reentrant or ConcurrencyMode.Muliple
See Chapter 5 of Programming WCF services for a good discussion of this
Probably your service has no ConcurencyMode set on it's behavior.
See something like [ServiceBehavior(ConcurencyMode=ConcurencyMode.Reentrant)]
or similar attributes (like CallbackBehavior)
I ran into the same kind of issue (callback hangs until timeout). I solved this problem by setting an attribute on the object implementing the callback interface:
[CallbackBehavior(UseSynchronizationContext = false)]