I have a duplex TCP connection between a Silverlight client and a WCF C# server. The server is constantly pushing updates up to the client. However after about ten minutes of user inactivity, any user operation that gets sent to the server results in an exception, although the updates continue successfully.
Given the period of time involved and the inactivity on the client side I’m guessing it involves the ReceiveTimeout setting. However when I attempt to set it on the client (see below), it doesn’t fix this.
CustomBinding binding = new CustomBinding(new BinaryMessageEncodingBindingElement(),
new TcpTransportBindingElement());
binding.ReceiveTimeout = TimeSpan.MaxValue;
EndpointAddress address = new EndpointAddress(testAddress);
testClient = new TestClient(binding, address);
Do I need to set this on the server side as well as or instead of the client side?
If I do need to set this on the server, how would I do this, as I’m using OperationContext.Current.GetCallbackChannel<ITestClient>() to get the callback interface?
The callback interface doesn’t give me access to properties to set timeouts and I’m not sure what to cast it to to enable this. I tried setting it on the ServiceHost on the server side but this also didn’t appear to fix it.
Turns out the answer is: it doesn’t matter. Setting it on the client side was technically correct, but according to Configuring Web Service Usage in Silverlight Clients:
I have since tested this and verified it was the case.
The answer ended up being implementing a keep alive call to the server once every four minutes (four minutes chosen because it’s half of the ten minute receive timeout, minus a buffer).