locked
issue with wsdualhttpbinding? RRS feed

  • Question

  •  I have two wcf services, service 1 hosted in IIS using wshttpbinding and service 2 hosted in Console app using nettcpbinding.

    I have a Wpf client app which connects to both the services. Now I need to replace the nettcpbinding service with wsdualhttpbinding to avoid port enabling issues. (dualhttpbinding used because of call back functionality).

    If I use nettcpbinding and if the relevant ports are open, the client is able to connect to service with no issues.

    If I use wsdualhttpbinding the client is sometimes able to connect and sometimes doesn't. If it doesn't connect it results in the below issue.

    WCF Service Exception : -> System.TimeoutException: The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout.

    Server stack trace: 
       at System.ServiceModel.Channels.TransmissionStrategy.WaitQueueAdder.Wait(TimeSpan timeout)
       at System.ServiceModel.Channels.TransmissionStrategy.InternalAdd(Message message, Boolean isLast, TimeSpan timeout, Object state, MessageAttemptInfo& attemptInfo)
       at System.ServiceModel.Channels.ReliableOutputConnection.InternalAddMessage(Message message, TimeSpan timeout, Object state, Boolean isLast)
       at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.DuplexChannel.Send(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.DuplexChannelBinder.Send(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at RemoteDevice.ServiceLibrary.ServiceContracts.IDeviceInteractServiceCallback.LogCatCallback(String log)
       at RemoteDevice.ServiceLibrary.DeviceSpecific.AndroidDeviceHolder.Proc_OutputDataReceived(Object sender, DataReceivedEventArgs e) in D:\RAF_1_1\Server\Service\RemoteDevice.ServiceLibrary\RemoteDevice.ServiceLibrary\DeviceSpecific\AndroidDeviceHolder.cs:line 196 : 
    Trace -> AndroidClientHodler:Proc_OutputDataReceived

    WPF CLIENT EXCEPTION;2/4/2014 11:55:04 AM;Source;mscorlib;Method;HandleReturnMessage;Computer;LP-3C970E68CDE8;ExceptionMessage;The open operation did not complete within the allotted timeout of 00:00:59.9679968. The time allotted to this operation may have been a portion of a longer timeout.;TraceInfo;FetchAllDetails;StackTrace;Server stack trace: 
       at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
       at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ClientBase`1.Open()
       at RemoteDeviceClient.Model.ServiceConnectionBase.<>c__DisplayClass1.<createCustomServiceClientObject>b__0() in D:\RAF_1_1\Client\RemoteDeviceClient.Model\ServiceConnectionBase.cs:line 74

    Service creation code:

                //Define base addresses so all endPoints can go under it
    
                Uri tcpAdrs = new Uri("net.tcp://" + ipHostInfo.AddressList[0].ToString() + ":" +
                    textBoxPort + "/service/");
    
                //Uri httpAdrs = new Uri("http://" + ipHostInfo.AddressList[0].ToString() + ":" +
                //    (int.Parse(textBoxPort.ToString()) + 1).ToString() + "/service/");
    
                Uri httpAdrs = new Uri("http://" + ipHostInfo.AddressList[0].ToString() + "/service/");
    
                Uri[] baseAdresses = { tcpAdrs, httpAdrs };
    
                host = new ServiceHost(typeof(RemoteDevice.ServiceLibrary.ServiceImplementation.DeviceInteractService), baseAdresses);
    
                NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None, true);
                //Updated: to enable file transefer of 64 MB
                tcpBinding.MaxBufferPoolSize = (int)67108864;
                tcpBinding.MaxBufferSize = 67108864;
                tcpBinding.MaxReceivedMessageSize = (int)67108864;
                tcpBinding.TransferMode = TransferMode.Buffered;
                tcpBinding.ReaderQuotas.MaxArrayLength = 67108864;
                tcpBinding.ReaderQuotas.MaxBytesPerRead = 67108864;
                tcpBinding.ReaderQuotas.MaxStringContentLength = 67108864;
                
    
                tcpBinding.MaxConnections = 100;
                //To maxmize MaxConnections you have to assign another port for mex endpoint
    
                //and configure ServiceThrottling as well
                ServiceThrottlingBehavior throttle;
                throttle = host.Description.Behaviors.Find<ServiceThrottlingBehavior>();
                if (throttle == null)
                {
                    throttle = new ServiceThrottlingBehavior();
                    throttle.MaxConcurrentCalls = 100;
                    throttle.MaxConcurrentSessions = 50;
                    host.Description.Behaviors.Add(throttle);
                }
    
                //Enable reliable session and keep the connection alive for 20 hours.
                tcpBinding.ReceiveTimeout = new TimeSpan(20, 0, 0);
                tcpBinding.ReliableSession.Enabled = true;
                tcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(20, 0, 10);
    
                host.AddServiceEndpoint(typeof(RemoteDevice.ServiceLibrary.ServiceContracts.IDeviceInteractService), tcpBinding, "tcp");
    
    
                //WSHttpBinding httpBinding = new WSHttpBinding();
                WSDualHttpBinding httpBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None);
                //httpBinding.CloseTimeout = new TimeSpan(0, 3, 0);
                //httpBinding.OpenTimeout = new TimeSpan(0, 3, 0);
                httpBinding.ReceiveTimeout = new TimeSpan(20,0,0);
                //httpBinding.SendTimeout = new TimeSpan(0, 3, 0);
                //httpBinding.BypassProxyOnLocal = true;
                //httpBinding.TransactionFlow = false;
                //httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                httpBinding.MaxBufferPoolSize = (int)67108864;
                httpBinding.MaxReceivedMessageSize = (int)67108864;
                httpBinding.MessageEncoding = WSMessageEncoding.Text;
                httpBinding.TextEncoding = System.Text.Encoding.UTF8;
                httpBinding.UseDefaultWebProxy = false;
                //httpBinding.AllowCookies = false;
                httpBinding.ReaderQuotas.MaxDepth = 32;
                httpBinding.ReaderQuotas.MaxStringContentLength = 67108864;
                httpBinding.ReaderQuotas.MaxArrayLength = 67108864;
                httpBinding.ReaderQuotas.MaxBytesPerRead = 67108864;
                //httpBinding.ReaderQuotas.MaxNameTableCharCount = 16384;
                httpBinding.ReliableSession.Ordered = true;
                httpBinding.ReliableSession.InactivityTimeout = new TimeSpan(20,0,10);
                //httpBinding.ReliableSession.Enabled = false;
                //httpBinding.Security.Mode = SecurityMode.Message;
                //httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                //httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                //httpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
                //httpBinding.Security.Message.NegotiateServiceCredential = true;
                //httpBinding.Security.Message.EstablishSecurityContext = true;
                
    
                host.AddServiceEndpoint(typeof(RemoteDevice.ServiceLibrary.ServiceContracts.IDeviceInteractService), httpBinding, "deviceservice");
    
                //Define Metadata endPoint, So we can publish information about the service
                ServiceMetadataBehavior mBehave = new ServiceMetadataBehavior();
                host.Description.Behaviors.Add(mBehave);
    
                host.AddServiceEndpoint(typeof(IMetadataExchange),
                    MetadataExchangeBindings.CreateMexTcpBinding(),
                    "net.tcp://" + ipHostInfo.AddressList[0].ToString() + ":" +
                    (int.Parse(textBoxPort.ToString()) - 1).ToString() + "/service/mex");
    
    
                host.AddServiceEndpoint(typeof(IMetadataExchange),
                   MetadataExchangeBindings.CreateMexHttpBinding(),
                   "http://" + ipHostInfo.AddressList[0].ToString() + "/service/mex");

    My wpf client app.config is below.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <appSettings>
        <add key="FirstAlertTime" value="30" />
        <add key="SecondAlertTime" value="15" />
        <add key="MessageAlertTime" value="5" />
        <add key="ClientSettingsProvider.ServiceUri" value="" />
        <add key="EventViewerLogging" value="true"/>
        <add key="FileLogging" value="true"/>
        <!--give connection protocol as either http or tcp-->
        <add key="ConnectionProtocol" value="http"/>
      </appSettings>
    
      <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="NetTcpBinding_IDeviceInteractService" closeTimeout="00:10:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                maxBufferPoolSize="67108864" maxBufferSize="67108864" maxConnections="10"
                maxReceivedMessageSize="67108864">
              <readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="67108864"
                  maxBytesPerRead="67108864" maxNameTableCharCount="67108864" />
              <reliableSession ordered="true" inactivityTimeout="20:00:10"
                  enabled="true" />
              <security mode="None">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
          <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IDeviceInteractService" closeTimeout="00:10:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                transactionFlow="false" bypassProxyOnLocal="true"  hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="67108864" maxReceivedMessageSize="67108864"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="false">
              <readerQuotas maxDepth="32" maxStringContentLength="67108864"
                  maxArrayLength="67108864" maxBytesPerRead="67108864" maxNameTableCharCount="67108864" />
              <reliableSession ordered="true" inactivityTimeout="20:00:10" />
              <security mode="None">
                <message clientCredentialType="Windows"/>
              </security>
            </binding>
          </wsDualHttpBinding>
          <wsHttpBinding>
            <binding name="WSHttpBinding_IManagementService" 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"
                allowCookies="false">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                  enabled="false" />
              <security mode="None">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="net.tcp://10.108.40.198:200/service/tcp" binding="netTcpBinding"
                      bindingConfiguration="NetTcpBinding_IDeviceInteractService"
                      contract="DeviceService.IDeviceInteractService" name="NetTcpBinding_IDeviceInteractService" />
          <endpoint address="http://10.108.40.198/service/deviceservice"
              binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IDeviceInteractService"
              contract="DeviceService.IDeviceInteractService" name="WSDualHttpBinding_IDeviceInteractService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
          <endpoint address="http://10.108.40.198/ManagementService/ManagementService.svc"
              binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IManagementService"
              contract="ManagementService.IManagementService" name="WSHttpBinding_IManagementService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
        </client>
      </system.serviceModel>
    </configuration>
      [ServiceContract(CallbackContract = typeof(IDeviceInteractServiceCallback), SessionMode = SessionMode.Required)]
        public interface IDeviceInteractService
        {
            [OperationContract(IsInitiating = true)]
            ConnectionResponse Connect(ConnectionRequest connectionRequest);
    ...
    ...
    }
     public interface IDeviceInteractServiceCallback
        {
            [OperationContract(IsOneWay = true)]
            void ReceiveStream(byte[] msg);
    ...
    ...
    }
      [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
        ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
        public class DeviceInteractService : IDeviceInteractService, IDisposable
        {
            List<String> listOfUserRequesting = new List<string>();
    
    ...
    ...
    }
    Please help me if i am missing any configuration/settings and resolve this issue.


    • Edited by ykbharat Tuesday, February 4, 2014 7:59 AM edited
    Tuesday, February 4, 2014 7:48 AM

Answers

  • Hi,

    The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout

    As the error said, maybe you need to increase the timeout value, such as the openTimeout value:

       <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IDeviceInteractService" closeTimeout="00:20:00"
                openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
                 ..............
              <security mode="None">
                <message clientCredentialType="Windows"/>
              </security>
            </binding>
          </wsDualHttpBinding>
    

    Also please try to check those similar threads:
    http://stackoverflow.com/questions/4273195/wcf-having-trouble-with-one-way-callbacks .
    http://stackoverflow.com/questions/14938968/wcf-duplex-nettcp-callbacks-not-working .

    Best Regards,
    Amy Peng



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 7, 2014 6:30 AM