问题 http server: package main import ( "log" "net/http" ) func main() { // 启动HTTP服务 addr := "127.0.0.1:8080" // 添加agent的websocket处理 http.HandleFunc("/agent", agentHandler) err := http.ListenAndServe(addr, nil) log.Fatal(err) } func agentHandler(w http.ResponseWriter, r *http.Request) { } http client用telnet模拟(不涉及http消息的收发,只是连接) telnet 127.0.0.1 8080 用tcpdump和strace发现server端开启了15秒的tcp keepalive,但是看代码只有默认为30秒的设置,很奇怪: $ strace ./s 2>&1 | grep setsockopt setsockopt(3, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 // 上面是客户端连接前输出的,下面是客户端连接后输出的 setsockopt(4,