最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to detect on server when a http client disconnects - Stack Overflow

programmeradmin0浏览0评论

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)?

发布评论

评论列表(0)

  1. 暂无评论