Question

I have configured my wcf with these timeouts:

  public static NetTcpBinding MakeTcpBinding(bool isClient)
  {
     return new NetTcpBinding(SecurityMode.None, false)
     {
        HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
        TransactionFlow = false,
        PortSharingEnabled = true,
        Security = {Transport = {ClientCredentialType = TcpClientCredentialType.None}},
        ReceiveTimeout = isClient ? TimeSpan.FromSeconds(5) : TimeSpan.FromDays(1),
        SendTimeout = isClient ? TimeSpan.FromSeconds(1) : TimeSpan.FromSeconds(5),
        OpenTimeout = TimeSpan.FromSeconds(1),
        CloseTimeout = TimeSpan.FromSeconds(5),
        MaxReceivedMessageSize = int.MaxValue,
        ListenBacklog = int.MaxValue,
        MaxBufferSize = int.MaxValue,
        MaxBufferPoolSize = 524288,
        ReaderQuotas =
        {
           MaxArrayLength = int.MaxValue,
           MaxStringContentLength = int.MaxValue,
           MaxDepth = int.MaxValue,
           MaxBytesPerRead = int.MaxValue,
           MaxNameTableCharCount = int.MaxValue
        }
     };
  }

Which should set the imeout to 1 second when a client connects to a non-existing server.

However, when actually calling open, I see a 21 second timeout.

DEBUG 2013-07-31 18:12:44,712 Communication.WcfCommunicator - NotifyAllReceivers: Type: AskWhoIsAwake, SentDate: 7/31/2013 18:12:44 AM, DetectSessionId: 37106dee-b563-458b-9eb7-a90e81f82563 - 1

DEBUG 2013-07-31 18:13:05,746 Communication.WcfCommunicator - Could not connect to net.tcp://notup/xxx.svc/motup_www-xxx-com. The connection attempt lasted for a time span of 00:00:00.9879988. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 42.42.42.42:808. - 6

What is causing the extra 20 second timeout?

Was it helpful?

Solution

Solved using the async open and setting timeout.

     var ar = client.InnerChannel.BeginOpen(null, null);
     if (!ar.AsyncWaitHandle.WaitOne(client.Endpoint.Binding.OpenTimeout, true))
        throw new CommunicationException("Service is not available");
     client.InnerChannel.EndOpen(ar);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top