Duplex MEP issue with wsDualHttpBinding

Hi,

In December CTP of WinFX, I tried implementing Duplex communication application with wsDualHttpBinding. I had gone through the following steps,

1. Creation of service contract (with session set to true) and callback contract.

2. The service is hosted in a console application with endpoint specfied in App.config file of host application.

3. My Client application is a console application that implements the callback contract.

4. My client application code also contains my service interface too.

5. I used svcutil to create typed proxy of service and client side configuration file content.

6. When i ran with whatever configuration file content created with svcutil, My client application fails with exception that states something like port 80 could not be used for callback response as it is already being used (Though my service ran in 8080 port).

 So, I customized bindings as follows and tried again

<configuration>

<system.serviceModel>

<client>

<endpoint

name="clientEndpoint"

address="http://localhost:8080/MySampleDuplexService"

bindingConfiguration="DuplexBinding"

binding="wsDualHttpBinding"

contract="IMySampleDuplexService" />

</client>

<bindings>

<wsDualHttpBinding>

<binding name="DuplexBinding" clientBaseAddress="http://localhost:8090/MySampleDuplexClient" >

</binding>

</wsDualHttpBinding>

</bindings>

</system.serviceModel>

</configuration>

This time, no exception occurs but i don't get my callback method being invoked in client side.

 

My client side code is

InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

using (MySampleDuplexServiceProxy sampleDuplexServiceProxy = new MySampleDuplexServiceProxy(instanceContext, "clientEndpoint" ) )

{

sampleDuplexServiceProxy.MyDuplexOperation("Duplex Operation!!!");

Thread.Sleep(5000);

sampleDuplexServiceProxy.Close();

}

 And my service and callback interfaces are

[ServiceContract(Session=true, CallbackContract=typeof(IMySampleDuplexCallback))]

public interface IMySampleDuplexService

{

[OperationContract(IsOneWay=true)]

void MyDuplexOperation(string myValue);

}

public interface IMySampleDuplexCallback

{

[OperationContract(IsOneWay=true)]

void MyDuplexCallbackOperation(string result);

}

And i am using  PerSession - InstanceContextMode service behavior in my implementation of service contract.

Can anybody help me to find out what is wrong in this approach

TIA,

Ganesan Krishnamurthy.

 

 



Answer this question

Duplex MEP issue with wsDualHttpBinding

  • Ntompson

    Hi Justin,

    Please see my client side code.

     

    ------------------------------------------------------------------------

     

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.ServiceModel;

    using System.Threading;

    namespace MyClientApplicationForDuplexService

    {

    public interface IMySampleDuplexCallback

    {

    [OperationContract]

    void MyDuplexCallbackOperation(string result);

    }

    public class CallbackHandler : IMySampleDuplexCallback

    {

    public void MyDuplexCallbackOperation(string result)

    {

    Console.WriteLine( "TEST :: " + result);

    }

    }

    class Program

    {

    static void Main(string[] args)

    {

    InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

    using (MySampleDuplexServiceProxy sampleDuplexServiceProxy = new MySampleDuplexServiceProxy(instanceContext, "clientEndpoint" ) )

    {

    sampleDuplexServiceProxy.MyDuplexOperation("Duplex Operation!!!");

    sampleDuplexServiceProxy.MyDuplexOperation("Test1");

    sampleDuplexServiceProxy.MyDuplexOperation("Test2");

    Thread.Sleep(5000);

    sampleDuplexServiceProxy.Close();

    }

    }

    }

    }

    ----------------------------------------------------

    I tried netstat command and client side seems to be up and listen.

     

    Thanks,

    Ganesan Krishnamurthy.


  • DarkCat

    You could also use the config file to set the client callback address:

    <bindings>

    <wsDualHttpBinding>

    <binding name="WSDualHttpBinding_IDuplexTest" clientBaseAddress="http://localhost:8000/myClient/" >

    </binding>

    </wsDualHttpBinding>

    </bindings>



  • Chris Anderson

    It happens on the client side because you have IIS running and it does not allow another application register port 80 (in this case, the callback channel).
    You can solve this issue by adding this to your client code:
    myHttpBinding.ClientBaseAddress = new Uri("http://localhost:8080/myApp/client");
    MySampleDuplexServiceProxy sampleDuplexServiceProxy = new MySampleDuplexServiceProxy(instanceContext, myHttpBinding, new EndpointAddress("Http://...");

  • alypeely

    Where is the implementation of your callbackhandler you appear to be newing one up, but I dont see the code.
     
    It should be something like:
     

    internal class CallbackHandler : IMySampleDuplexCallback

    {

        void MyDuplexCallbackOperation(string result){

        }

    }

    You may also want to use process explorer to check the addresses / ports your sender and receiver are listening on....



  • Martin Hart Turner

    Hi Steve,

    Thanks for your reply.

    I tried running the application after stopping the IIS service too. And the port - 8090 is not blocked by the firewall. It behaves the same manner.

    Regards,

    Ganesh.

     

     

     


  • Gooddogs.com

    1) Do you have IIS running On Windows XP, IIS 5.1 doesn't use HTTP.SYS for it's HTTP stack, so it hogs port 80 and prevents other processes from using it.

    2) Is port 8090 (the callback port) blocked by the Windows Firewall In duplex HTTP, each side of the MEP intitiates a connection back to the other, so both sides have to be externally addressable.

    HTH
    -steve


  • Duplex MEP issue with wsDualHttpBinding