Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi there,

I have a WCF service that detects when a client is no longer running. It also checks if that machine is still alive with a ping. If they are alive I wish to force a restart of the client app.

Does anyone know of an easy way to achieve this?

Regards,

Jib
Posted
Comments
Sergey Alexandrovich Kryukov 3-Dec-13 10:28am    
Bad idea. If it was possible, it would be a big abuse, anyway. If services could directly enforce anything on client side, who would ever trust them?
—SA

1 solution

You cannot directly do it, and you should not. Please see my comment to the question.

If the client is disconnected, it does not simply exist for the service. Everything is triggered by the initiative of the client, not service.

The fact that you can ping the client's host means nothing. When you can ping something, it means you communicate with some service, not client. To be successfully pinged, the host should run a server implementing the ICMP protocol:
http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol[^],
http://en.wikipedia.org/wiki/Ping_%28networking_utility%29[^].

Instead of thinking it the direction of total technology abuse, you should rather try to find a bug which causes your connection to break prematurely and fix it. This is a general and very important approach to engineering: don't try to cover up your and other's bugs with additional constructs.

—SA
 
Share this answer
 
Comments
Jibrohni 3-Dec-13 10:58am    
Thanks for the response, but the idea is to prevent people from killing the client process - therefore stopping reports going to the service. So if the client process is killed, I can have it auto-restart.
Sergey Alexandrovich Kryukov 3-Dec-13 11:31am    
No, you cannot, and you never should. If a client non-gracefully killed it, not due to a bug but intentionally, this is the prerogative of the client. Forcing a client to reconnect is impossible. And if it was possible, who would trust the services which are that intrusive? It would be a major safety fallacy. I suggest you accept it, and accept my answer formally.
—SA
Jibrohni 3-Dec-13 12:14pm    
Ok, so really the client should be prevented from killing the client process via access rights and proper privileges. And not the way I'm proposing. Thanks for the advice.
Sergey Alexandrovich Kryukov 3-Dec-13 12:20pm    
Yes, but not just that. You see, there are always some cases when the client disconnects non-gracefully, by whatever reason. The whole system may fail, get to the Blue Screen of Death, electro-shocked, to go to some extremes. As the service part serves many clients, it should developed with high tolerance to such disasters, including some bugs on client side. Service parts just carry more responsibilities. And this is quite possible. After all, you need to execute some outer processing cycle of each thread's code under try-catch and provide proper recovery.

You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900