views:

401

answers:

4

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

A: 

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.
tomasr
+1  A: 

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

Ian Ringrose
A: 

Probably your service has no ConcurencyMode set on it's behavior.

See something like [ServiceBehavior(ConcurencyMode=ConcurencyMode.Reentrant)] or similar attributes (like CallbackBehavior)

Alex Stankiewicz
+1  A: 

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)]
20c
+1, Thanks for this answer, my callback actually gets called-back now :)
Codesleuth