I'm trying to use a WCF reliable session to enable callbacks from the service to the client. This callback channel needs to be open indefinitely.
There seems to be a bug in some .NET versions that lets reliable sessions fault prematurely. Should be no problem, just set the inactivityTimeout and receiveTimeout to values that are high enough (e.g. TimeSpan.MaxValue
).
But no matter how I configure my client and services, the channel still faults after 10 minutes, regardless of the value I set as timeout.
This question would be incomplete without my config, so here it goes:
<!-- service's app.config -->
<!-- irrelevant stuff snipped .. -->
</binding>
<netTcpBinding>
<!-- enable reliable sessions, set timeouts to their maximum possible value!!! -->
<binding name="netTcpReliable" receiveTimeout="infinite">
<reliableSession enabled="true" inactivityTimeout="infinite"/>
</binding>
</netTcpBinding>
</binding>
<services>
<service name="SomeService" behaviorConfiguration="metadataBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:port/SomeService"/>
</baseAddresses>
</host>
<endpoint name="SomeService_BasicTcpEndpoint"
address="service"
binding="netTcpBinding"
bindingConfiguration="netTcpReliable"
contract="ISomeService" />
</service>
<services>
// client's binding generation code
var binding = new NetTcpBinding(SecurityMode.Transport, true) // enable reliable session
{
OpenTimeout = openCloseTimeout,
CloseTimeout = openCloseTimeout,
SendTimeout = sendTimeout,
ReceiveTimeout = TimeSpan.MaxValue // maximum possible value (infinite in app.config)
};
binding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue; // maximum possible value (infinite in app.config)
var factory = new ChannelFactory<TChannel>(binding);
return factory.CreateChannel(endpointAddress);
So, as you can see, all timeouts are configured to values higher than 10 minutes, and still the channel faults precisely after 10 minutes without any service call. How can I circumvent this? As far as I understood it, reliable sessions are (amongst other things) used exactly for that: keeping channels alive and prevent them from faulting (by sending infrastructure keep alive packets – at least in recent .NET versions without the aforementioned bug).
You should have gotten warnings during compile that infinite is no legal value for the timeouts. The maximun timeout is about 24 days.