WCF deadlock when using callback channel
- by mafutrct
This is probably a simple mistake, but I could not figure out what was wrong. I basically got a method like this:
[ServiceBehavior (
ConcurrencyMode = ConcurrencyMode.Reentrant,
InstanceContextMode = InstanceContextMode.PerSession,
IncludeExceptionDetailInFaults = true)
]
public class Impl : SomeContract
{
public string Foo() {
_CallbackChannel.Blah();
return "";
}
}
Its interface is decorated:
[ServiceContract (
Namespace = "http://MyServiceInterface",
SessionMode = SessionMode.Required,
CallbackContract = typeof (WcfCallbackContract))
]
public interface SomeContract
{
[OperationContract]
string Foo ();
}
The service is hosted like this:
ServiceHost host = new ServiceHost (typeof (Impl));
var binding = new NetTcpBinding ();
var address = new Uri ("net.tcp://localhost:8000/");
host.AddServiceEndpoint (
typeof (SomeContract),
binding,
address);
host.Open ();
The client implements the callback interface and calls Foo. Foo runs, calls the callback method and returns. However, the client is still struck in the call to Foo and never returns. The client callback method is never run.
I guess I made a design mistake somewhere. If needed, I can post more code. Any help is appreciated.