WCF deadlock when using callback channel

Posted by mafutrct on Stack Overflow See other posts from Stack Overflow or by mafutrct
Published on 2010-03-13T11:57:57Z Indexed on 2010/03/13 12:05 UTC
Read the original article Hit count: 815

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf