Question

I've got a service and have verified using "netstat -anb" that when the service is running, it's listening on the correct port (8040). The service contract contains the following contract:

    [OperationContract]
    bool RegisterPlayer();

The service class itself implements the contract explicitly:

    bool IMechService.RegisterPlayer()
    {
        if (P1 != null)
        {
            P1 = OperationContext.Current.GetCallbackChannel<IMechServiceCallback>();
            return true;
        }
        else if (P2 != null)
        {
            P2 = OperationContext.Current.GetCallbackChannel<IMechServiceCallback>();
            return true;
        }
        return false;
    }

And the svcutil generated proxy creates the following method:

public bool RegisterPlayer()
{
    return base.Channel.RegisterPlayer();
}

This code attempts to generate a proxy and call the method. I've tried both using DuplexChannelFactory and the svcutil generated proxy class, and both give the same results:

client = new MechServiceClient(new InstanceContext(this));
//client = DuplexChannelFactory<IMechService>.CreateChannel(this, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8040/MechService"));
client.RegisterPlayer();

Code execution reaches the RegisterPlayer in the proxy class, but proceeds to time out, never running RegisterPlayer on the service. Unfortunately, as it's just timing out, I'm not getting any exceptions or errors to help indicate where to look for issues. So far, I've verified the service is running and appears to be listening on port 8040 using "netstat -anb", and I've established that the mex endpoint is working as intended and publishing metadata. I turned off Windows Firewall. I've also created a separate test project with much simpler implementations to verify I was doing the steps correctly, and the simpler test project works fine. I'm out of ideas for what's causing this to fail, and any advice would be appreciated.

Was it helpful?

Solution 2

Andrew's suggestion to logging helped, basically what fixed it was declaring my OperationContracts to isoneway=true.

OTHER TIPS

Have you tried setting the ConcurrencyMode to ConcurrencyMode.Multiple?

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
class MechServiceImpl : IMechService
{
    // ..
}

The default concurrency mode for a service is ConcurrencyMode.Single, which can cause complications with callbacks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top