1

I worked through building a WCF duplex service on my development machine. I built the service, created a test client, tested everything and it works. . Then I got gutsy and moved it to my production server.Now that I've moved to the production server I can't use the duplex service. block for sometime and give timeout error

Service web.config

<?XML version="1.0"?>
<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>      
    <compilation debug="true" target Framework="4.0">
    </compilation>    
    <authentication mode="Windows"/>       
    <pages compatibility="3.5" client ID Mode="Auto ID"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WCFDuplex.Service1" behaviorConfiguration="WCFDuplex.Service1Behavior">
        <endpoint address="http://Productionserver:8088/sampleWCF/Service1.svc" binding="wsDualHttpBinding" contract="WCFDuplex.IServiceDuplex">
          <identity>
            <dns value="Productionserver"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFDuplex.Service1Behavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Client app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IServiceDuplex" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" > 
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:01:00" />
          <security mode="Message">  
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://Productionserver:8088/sampleWCF/Service1.svc" binding="wsDualHttpBinding"
      bindingConfiguration="WSDualHttpBinding_IServiceDuplex" contract="IServiceDuplex"
      name="WSDualHttpBinding_IServiceDuplex">
        <identity>
          <dns value="Productionserver" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

Client code:

        static void Main(string[] args)
        {
            EndpointAddress endPointAddress = new EndpointAddress("http://ProductionServer:8088/sampleWCF/Service1.svc");
            try
            {                  
                InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
                ServiceDuplexClient client = new 
                    ServiceDuplexClient(instanceContext, new WSDualHttpBinding(), endPointAddress);

                client.ClientCredentials.UserName.UserName = "bipin";
                client.ClientCredentials.UserName.Password = "pass@123";

                client.Open();

                client.GetDataFromXml();
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error connecting to service. {0}", ex.Message));
            }
            Console.ReadLine();
        }

I getting error when open proxy : i.e client.Open();

Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00). Source=mscorlib

Please help me to sort out this error. any help will be appreciable. thanks.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
Goldy Sonata
  • 65
  • 11

1 Answers1

0

My advice is not to use WSDualHttpBinding for Duplex - the whole model it uses is very prone to failure and doesn't work through any robustly configured firewall

Switch to NetTcpBinding for duplex. The client creates an outbound connection to the server and then this same connection is used to pass the duplex messages (WSDualHttpBinding tries to establish another connection from server to client which is will almost certainly be blocked in production networks

I blogged about this here

Richard Blewett
  • 6,089
  • 1
  • 18
  • 23
  • yes richard, our application doesn't work without disabling firewall, even though while data sync server to client vice versa. application give's sometime strange service model exception and after it crashes the application. – Goldy Sonata Jan 20 '12 at 10:33
  • As I said, WSDualHttpBinding is pretty flaky and requires a connection to be established from server to client. However, there is a general issue with duplex that you need to be aware of - in that is a session based model and therefore the sessions can timeout on either side (timeout is controlled by the receiveTimeout on both ends and defaults to 10 minutes) could this be your problem? – Richard Blewett Jan 20 '12 at 11:40
  • as u said use net.tcp binding for duplex wcf. now it's work but when i see major problem is accessing this service on window 7 machine it's works great. but on some client window xp machine getting error. endpointnotfound exception. i am really confused why is so happened because this service accessible on window 7 and some window xp as i know but some window xp machine not opening proxy ..... plase give me suggestion.. what i have to do to work this service on both window 7 and window xp machine with all major sp 2 and sp3. – Goldy Sonata May 28 '12 at 13:51
  • There is nothing inherent on Windows XP that will stop it using NetTcpBinding. Our product uses duplex NetTcpBinding with clients on both Windows 7 and XP. I know it works on SP3 - I'm not aware of issues on SP2 but I don't have a test rig to verify that. Is the issue you are seeing related to SP2 vs SP3? – Richard Blewett May 30 '12 at 10:27