detecting server crash during long-polling http request
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 w开发者_如何学Chen the server crashes?
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.
精彩评论