我有以下go代码:
package main
import (
"net/http"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
e.POST("/getRequestData", respond)
e.Logger.Fatal(e.Start(":80"))
}
func respond(c echo.Context) error {
resp := map[string]string{ "value": "key"}
return c.JSON(http.StatusOK, resp)
}我希望通向此服务器的连接将在10分钟内保持不活动。我看到的是,每隔几分钟我就会收到来自服务器的Ack,这会导致它无限期地保持打开状态。如何在go中关闭keep-Alive?
谢谢。
发布于 2021-06-01 15:29:45
这在2011年的issue 2011 (服务器端)中提到过,并在commit ac213ab中得到了解决。
这允许像DisableKeepAlives to true, and MaxIdleConnsPerHost to -1一样设置HTTP.Transport configuration,并尊重这些设置。
但是,如果您需要对implementing an Hijacker连接进行更多的控制,也可以选择将in here作为TCP。
https://stackoverflow.com/questions/67783759
复制相似问题