Scenario:

The user sits in the client and closes it via ctrl + alt + del.

When I first access the service method, I do this:

if (channel == null) { channel = OperationContext.Current.Channel; channel.Closed += UnlockDictionary; channel.Faulted += UnlockDictionary; Dictionary_id = dictionary_id; } 

And the event is triggered on the side of the service, for example, when you exit the using context on the client.

However, if the user does ctrl + alt + del, then I don’t get into this event, although the user called one of the methods => the link to the channel was saved.

    1 answer 1

    There are two options:

    1. Implement independently some semblance of the "Ping" mechanism, i.e. The client should regularly call the server method and if the server did not receive the request from the client on time, then consider that the client disconnected. If you have bidirectional binding, then you can do the opposite - to call a client from the server and as soon as you get an exception, the client is gone.
    2. Enable a reliable session at the binding level and set inactivityTimeout. The infrastructure of a reliable session sends such ping requests with a period of half inactivityTimeout. Here (however, in English SO) in more detail: https://stackoverflow.com/questions/26732515/keepalive-with-wcf-and-tcp