I have a client-server application, the client access a wcf service.
I also have a KeepAlive timer. When the timer is elapsed - the WS send the client Callback.Ping request, in order to make sure that the client is still active.
For some reason, when two (or more) clients are connected, one of them will crash while trying to execute Callback.Ping, and get the following exception:
The operation 'Ping' could not be completed because the session channel timed out waiting to receive a message. To increase the timeout, either set the receive Timeout property on the binding in your configuration file, or set the ReceiveTimeout property on the binding directly.
I'll mention that both client and WS configuration files have declaration of receiveTimeout, sendTimeout, openTimeout and closeTimeout
, set to 10:00:00
minutes.
Can anybody help me to solve my problem please?
Edit:
app.config (client):
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IRouterClient" receiveTimeout="10:00:00" sendTimeout="10:00:00" openTimeout="10:00:00" closeTimeout="10:00:00"/>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="xxx.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IRouterClient"
contract="Client.IRouterClient"
name="WSDualHttpBinding_IRouterClient">
</endpoint>
</client>
</system.serviceModel>
Web.config (server):
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="xxx.WS.RouterClient">
<endpoint address="" binding="wsDualHttpBinding" contract="xxx.WS.IRouterClient" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsDualHttpBinding>
<binding openTimeout="00:00:20" closeTimeout="00:00:20" sendTimeout="00:00:10" receiveTimeout="00:05:00"/>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
When timer is elapsed, the service calls Ping:
public class SubscribedCustomer
{
public IServerCallback Callback;
public SubscribedCustomer(IServerCallback callback)
{
Callback = callback;
}
public void Ping(List<int> itemIds, IServerCallback serverCallback = null)
{
try
{
Callback.Ping(itemIds);
}
catch (Exception ex)
{
if (serverCallback != null)
{
Callback = serverCallback;
//recursive call with the new servercallback set
Ping(itemIds);
}
else
{
SetClientNotRunning("No reply from client");
}
}
}
}
The server contract:
public interface IServerCallback
{
[OperationContract(IsOneWay = true)]
void Ping(List<int> itemIds);
}
Thanks !