1

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 !

Tali B.
  • 125
  • 1
  • 11
  • You are using binding that uses reliable sessions. This is not the same timeout as receive/send. Check this SO [WCF Session Timeout](http://stackoverflow.com/questions/968939/wcf-session-timeout) and see if that helps. Otherwise you need to post full details about the client and service configuration and implementation details. – Petar Vučetin Mar 09 '16 at 22:46
  • Hi @PetarVučetin. I don't use reliable sessions in my config files. I've read the link you mentioned, it is pretty interesting but it doesn't seems to be appropriate to my case. I've updated my code above. What do tou think? – Tali B. Mar 10 '16 at 07:37
  • Please post your service contract & service implementation code in order for us to be able to see what is wrong. – Marc Selis Mar 10 '16 at 10:23
  • Hey @MarcSelis . Thanks for your comment. Updated my code above. – Tali B. Mar 10 '16 at 12:21
  • @MarcSelis Do you have any advice for me? – Tali B. Mar 13 '16 at 07:59
  • A dual http connection is in essence a combination of 2 one-way connections. The client calls the service and the service calls the client. That is why it is important to have the service defintions (interface contract & implementation) of both the client and the service to see what is wrong. That means the IClient interface and implementation and IServer interface and implementation, as both the contract (interface) and the implementation can have specific attributes that tell WCF how to behave. – Marc Selis Mar 14 '16 at 09:25

0 Answers0