I have a few computers working as WCF clients and they are connected to a computer who works as the WCF service.
Now lets say one client connection is lost (i.e. the cable disconnects), How can I know that happened on the service side?
I tried to use the wcf callbacks events Closing/Closed but I did not get the call.
I am writing in C#.
Best Regards.
Adi.
Callbacks dont work because your client cannot tell to service "i'am close connection with you".
What you need is heartbeat - periodic signal generated by your client to indicate normal operation. If service dont recieve this signal from one of clients in time it can guess that this client lost connection.
Also, you need a way to distinguish one client from another on service-side. For examle, every client can pass unique id in heartbeat signal.
Your service should not care whether a network cable was disconnected. One feature of TCP is that unless someone is actively sending data, it can tolerate momentary interruptions in network connectivity.
This is even more true in WCF, where there are layers of extra framework to help protect you against network unreliability.
The main thing you would accomplish by attempting to detect disconnection of a client is reduced reliability and availability.