views:

80

answers:

1

I'm having quite some trouble with the WCF Callback mechanism. They sometimes work but most of the time they don't.

I have a really simple Interface for the callbacks to implement:

public interface IClientCallback {
  [OperationContract]
  void Log(string content);
}

I then implmenent that interface with a class on the client:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] [ServiceContract]
internal sealed class ClientCallback : IClientCallback {
  public void Log(String content){
    Console.Write(content);
  }
}

And on the client I finally connect to the server:

NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.Transport);
EndpointAddress endpoint = new EndpointAddress("net.tcp://127.0.0.1:1337");
ClientCallback callback= new ClientCallback();
DuplexChannelFactory<IServer> factory = new DuplexChannelFactory<IServer>(callback,tcpbinding, endpoint);
factory.Open();
_connection = factory.CreateChannel();
((ICommunicationObject)_connection).Faulted += new EventHandler(RecreateChannel);
try {
  ((ICommunicationObject)_connection).Open();
} catch (CommunicationException ce) {
  Console.Write(ce.ToString());
}

To invoke the callback I use the following:

OperationContext.Current.GetCallbackChannel().Log("Hello World!");

But it just hangs there, and after a while the client complains about timeouts. Is there a simple solution as to why?

+1  A: 

sounds like a problem with .ClientConfig, could you post it here please?

VoodooChild
Maybe I should have mentioned that I have inherited the code and am all but a C# expert. Can you tell me where I can find that particular information?
cdecker