Reputation: 3480
I'm trying to learn WCF to use it as an IPC mechanism for a host/plugin system. The host needs to be able to call the plugin to Start/Stop it, and the plugin needs to call the server back to perform logging.
I made a simple test case where the host creates an endpoint on net.pipe://localhost/SampleServer
with the following ServiceContract:
[ServiceContract]
public interface IWcfServer
{
[OperationContract]
void Log(string message);
}
And the plugin creates an endpoint on net.pipe://localhost/SampleClient
with the following ServiceContract:
[ServiceContract]
public interface IWcfClient
{
[OperationContract]
string Init();
}
Here's a sample of how I'm setting up each endpoint:
this.server = new ServiceHost(this);
this.server.AddServiceEndpoint(typeof(IWcfServer),
new NetNamedPipeBinding(),
"net.pipe://localhost/SampleServer");
this.server.Open();
And here's a sample of how I'm making the calls:
ChannelFactory<IWcfClient> factory = new ChannelFactory<IWcfClient>(
new NetNamedPipeBinding(),
new EndpointAddress("net.pipe://localhost/SampleClient"));
IWcfClient client = factory.CreateChannel();
using ((IClientChannel)client)
{
client.Init());
}
I already confirmed that the host can call plugin.Init()
, and the plugin can call host.Log(message)
without issues. However, if this following scenario happens:
The applications freezes, and I get a TimeoutException
after 1min. Anyone has any ideas on what I'm doing wrong?
Upvotes: 2
Views: 3596
Reputation: 1
"net.pipe://localhost/SampleServer" "net.pipe://localhost/SampleClient" You have two different URL for the Server and for the Client. It is a problem!
Upvotes: 0
Reputation: 46
what is the InstanceContextMode of the service host ? If it is a singleton, it will block until Init() returns - resulting in a circular dependency.
Upvotes: 3
Reputation: 444
Turn on E2E tracing for WCF to check what exactly is timing out. - http://msdn.microsoft.com/en-us/library/ms733025.aspx. Besides your methods might be causing a deadlock since init might require log and log might require init to happen first or something like that.
Upvotes: 0
Reputation: 65371
1 min is the standard wcf timeout.
Do you have a circular reference?
Also, why do you have 2 contracts, when you make a call to client.init who is listening?
Upvotes: 0