none
Problem using netTcpBindung and reliableSession RRS feed

  • Question

  • Hi!

    I've got a problem getting reliable sessions to work. From what I've read so far, when reliable sessions are enabled, wcf sends some sort of idle message in order to keep the channel open. And this should happen at roughly half the time of the inactifity timeout. So, here's my config for the server:

      <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="MyBinding" receiveTimeout="00:01:00">
              <reliableSession ordered="true" inactivityTimeout="00:01:00" enabled="true" />
            </binding>
          </netTcpBinding>
        </bindings>
        <services>
          <service name="WcfBiDi.Service1" behaviorConfiguration="MetadataBehavior">
            <endpoint address="" binding="netTcpBinding" bindingConfiguration="MyBinding" contract="WcfBiDi.IService1" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:1025/Service1/" />
                <add baseAddress="http://localhost:8000/MyService"/>
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="NewBehavior0" />
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="MetadataBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    The client app.config looks like this:

        <system.serviceModel>
            <bindings>
                <netTcpBinding>
                    <binding name="NetTcpBinding_IService1" receiveTimeout="00:01:00">
                        <reliableSession inactivityTimeout="00:01:00" enabled="true" />
                    </binding>
                </netTcpBinding>
            </bindings>
            <client>
                <endpoint address="net.tcp://localhost:1025/Service1/" binding="netTcpBinding"
                    bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
                    name="NetTcpBinding_IService1">
                </endpoint>
            </client>
        </system.serviceModel>

    And after a few minutes of idle time, requests and callbacks don't work anymore.

    (Btw, the server runs in a WPF application, so it's self hosted.)

    So far I haven't had any idea about how to make it work properly. Can anyone help me?

    Lots of Greetings!

    Volker

    Tuesday, January 21, 2014 1:34 PM

Answers

  • Hi,

    From your code, I see that you have set the receiveTimeout and inactivityTimeout .

    Before using the reliableSession, we should know what are the receivetimeout and InactivityTimeout .

    In your example the receiveTimeout and inactivityTimeout are 1 minute, then for the receiveTimeout, if the server and client has no activity in a channel, then after 1 minute, the server will close the channel.
    Then for the inactivityTimeout, if the server and client disconnect, then it can keep the channel for 1 minute without activity.

    And you said after a few minutes of idle time, requests and callbacks didn't work anymore, of course it did not work. Because your receiveTimeout and inactivityTimeout are 1 minute, so you have to increase the value of the receiveTimeout and inactivityTimeout.

    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.




    Wednesday, January 22, 2014 8:27 AM
    Moderator
  • Hi,

    Yes, I am sorry the max timeout value is about 24 days.
    Maybe you can do this, just set the recevicetimeout and inactivityTimeout to 24 days. As I post in my eary reply:
    If the recevicetimeout and inactivityTimeout is 24 days. Then for the receiveTimeout, if the server and client has no activity in a channel, then after 24 days, the server will close the channel. So we can check whether the service is alive in every week to keep the channel open.

    if(serviceIsAlive())
    {
        callService();
    }
    else
    {
        handleFailure()
    }

    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.

    • Marked as answer by v_he Tuesday, January 28, 2014 8:17 AM
    Thursday, January 23, 2014 10:04 AM
    Moderator

All replies

  • Hi,

    From your code, I see that you have set the receiveTimeout and inactivityTimeout .

    Before using the reliableSession, we should know what are the receivetimeout and InactivityTimeout .

    In your example the receiveTimeout and inactivityTimeout are 1 minute, then for the receiveTimeout, if the server and client has no activity in a channel, then after 1 minute, the server will close the channel.
    Then for the inactivityTimeout, if the server and client disconnect, then it can keep the channel for 1 minute without activity.

    And you said after a few minutes of idle time, requests and callbacks didn't work anymore, of course it did not work. Because your receiveTimeout and inactivityTimeout are 1 minute, so you have to increase the value of the receiveTimeout and inactivityTimeout.

    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.




    Wednesday, January 22, 2014 8:27 AM
    Moderator
  • Hi Amy!

    Lots of thanks for your relpy!

    I think I misunderstood those timers. My impression so far was not that after one minute of inactivity the channel closes, but that after half the inactivity timeout a keepalive message gets sent by the WCF infrastructure.

    So, here is what I really want to do:

    I have some clients connecting to a channel and registering a callback for a certain event. The server calls the callback whenever that event in the server occurs. Sometimes every 100ms, sometimes less than once a month, depending on the event type.

    Clients should stay connected forever.

    So, how would I do this properly?

    Lots of Greetings!

    Volker

    Wednesday, January 22, 2014 9:02 AM
  • Hi,

    If you want the clients can stay connected forever, you can set the following in the both side of the service and client:

    <netTcpBinding>
          <binding name="MyBinding" receiveTimeout="infinite">
            <reliableSession inactivityTimeout="infinite" enabled="true" ordered="true"/>
          </binding>
     </netTcpBinding>

    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.

    Wednesday, January 22, 2014 9:26 AM
    Moderator
  • Hi!

    Thanks a lot but whrn I set the bindings I get warnings during compile.

    2 for the Service:

    Warning	1	The 'receiveTimeout' attribute is invalid - The value 'infinite' is invalid according to its datatype 'String' - The Pattern constraint failed.	C:\Users\v.hetzer\Documents\Visual_Studio\Repository\WcfBiDi\WcfBiDi\App.config	15	51	WcfBiDiTCP
    Warning	2	The 'inactivityTimeout' attribute is invalid - The value 'infinite' is invalid according to its datatype 'String' - The Pattern constraint failed.	C:\Users\v.hetzer\Documents\Visual_Studio\Repository\WcfBiDi\WcfBiDi\App.config	16	62	WcfBiDiTCP
    

    and two for the client:

    Warning	3	Custom tool warning: Cannot import wsdl:binding
    Detail: An exception was thrown in a call to a policy import extension.
    Extension: System.ServiceModel.Channels.ReliableSessionBindingElementImporter
    Error: The InactivityTimeout assertion's Milliseconds attribute does not fall within the range this binding uses. The ReliableSessionBindingElement could not be created.
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='RobotServiceTcp']	C:\Users\v.hetzer\Documents\Visual_Studio\Repository\WcfBiDi\WcfClientLibrary\Service References\TcpService\Reference.svcmap	1	1	WcfTcpClientLibrary
    Warning	4	Custom tool warning: Cannot import wsdl:port
    Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
    XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='RobotServiceTcp']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='Service1']/wsdl:port[@name='RobotServiceTcp']	C:\Users\v.hetzer\Documents\Visual_Studio\Repository\WcfBiDi\WcfClientLibrary\Service References\TcpService\Reference.svcmap	1	1	WcfTcpClientLibrary
    


    and the service reference on the client is empty:

        <system.serviceModel>
            <bindings />
            <client />
        </system.serviceModel>

    Is there something I can do?

    Lots of Greetings!

    Volker



    Wednesday, January 22, 2014 11:32 AM
  • Hi!

    It's me again, apparently the highest timeout value is about 24 days. Will I need a kind of heartbeat message or is there another way?

    Lots of Greetings!

    Volker

    Wednesday, January 22, 2014 12:13 PM
  • Hi,

    Yes, I am sorry the max timeout value is about 24 days.
    Maybe you can do this, just set the recevicetimeout and inactivityTimeout to 24 days. As I post in my eary reply:
    If the recevicetimeout and inactivityTimeout is 24 days. Then for the receiveTimeout, if the server and client has no activity in a channel, then after 24 days, the server will close the channel. So we can check whether the service is alive in every week to keep the channel open.

    if(serviceIsAlive())
    {
        callService();
    }
    else
    {
        handleFailure()
    }

    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.

    • Marked as answer by v_he Tuesday, January 28, 2014 8:17 AM
    Thursday, January 23, 2014 10:04 AM
    Moderator