admin管理员组

文章数量:1306875

We're doing some heavy computing on our server and want to make sure we don't do too much work if the client has already lost interest and closed the connection. According to AI there are two ways to detect if a http connection (or tcp for that matter, as http is stateless) has disconnected:

  1. TCP connection close: Peer sends a TCP connection reset packet
  2. Keepalive mechanism: Server starts sending keepalive packets to the client to check if the connection is still alive.

Now I get number 2) but I don't get 1). It seems that a connection reset is usually only sent by the server side, is that correct? Or will it also be sent by http clients like for example pythons requests library or your favorite internet browser? What happens if I abort said python program or if my computer crashes? Will the server get a connection reset or will I have to fallback to mechanism number 2)?

本文标签: How to detect on server when a http client disconnectsStack Overflow