Keepalive
https://en.wikipedia.org/wiki/Keepalive
Description
A keepalive signal is often sent at predefined intervals, and plays an important role on the Internet.
After a signal is sent, if no reply is received the link is assumed to be down and future data will be routed via another path until the link is up again.
A keepalive signal can also be used to indicate to Internet infrastructure that the connection should be preserved.
Without a keepalive signal, intermediate NAT-enabled routers can drop the connection after timeout.
Since the only purpose is to find links that don't work or to indicate links that should be preserved, keepalive messages tend to be short and not take much bandwidth.
However, their precise明确的,精确的 format and usage terms depend on the communication protocol.
TCP keepalive
Transmission Control Protocol (TCP) keepalives are an optional feature, and if included must default to off.[1]
The keepalive packet contains null data.
In an Ethernet network, a keepalive frame length is 60 bytes, while the server response to this, also a null data frame, is 54 bytes.[citation needed]
There are three parameters related to keepalive:
- Keepalive time is the duration between two keepalive transmissions in idle空闲 condition状态. TCP keepalive period is required to be configurable and by default is set to no less than 2 hours.
- Keepalive interval is the duration between two successive keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received.
- Keepalive retry is the number of retransmissions to be carried out before declaring that remote end is not available.
Keepalive on higher layers
Since TCP keepalive is optional, various protocols (e.g. SMB[2] and TLS[3]) add a similar feature on top of it.
This is also common for protocols which maintain a session over a connectionless protocol, e.g. OpenVPN over UDP
Other uses
HTTP keepalive
The Hypertext Transfer Protocol uses the keyword "Keep-Alive" in the "Connection" header to signal that the connection should be kept open for further messages (this is the default in HTTP 1.1, but in HTTP 1.0 the default was to use a new connection for each request/reply pair).[6] Despite the similar name, this function is entirely unrelated.
http://web.archive.org/web/20110605181241/http://www.io.com/~maus/HttpKeepAlive.html
HTTP is a stateless protocol - this means that every request is independent of every other. Keep alive doesn’t change that. Additionally, there is no guarantee that the client or the server will keep the connection open. Even in 1.1, all that is promised is that you will probably get a notice that the connection is being closed. So keepalive is something you should not write your application to rely upon.
https://en.wikipedia.org/wiki/HTTP_persistent_connection
扩展阅读
https://forums.iis.net/t/1214586.aspx?Connection+keep+alive+not+in+Response+Header
https://serverfault.com/questions/136306/what-is-the-iis7-default-keepalive-time
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2015-07-25 Attribute