views:

30

answers:

1

I have a Java client that uses HttpClient to connect to a server and wait a response. The response may return after a long time (the client essentially waits for an event from the server).

Other than using timeouts, is there a way to detect when the server crashes?

A: 

Considering that a server which has "crashed" cannot be relied upon to send you a message indicating that it has crashed, no.

The solution is to use a timeout, to set an upper limit on the amount of time your client is willing to wait for a request.

matt b
I was looking for something like periodic heartbeat/ping
IttayD
If this is what you would like to do, then you would need to re-architect things on the server side - so that it can accept input from one thread/request, and be able to expose information about the processing of that input to a second thread/request. Another option is to use some sort of long-poll/comet connection from the server.
matt b