Reputation: 149
I have the following go code:
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)
}
I want that connections toward this server will be open up to 10 min of inactivity. What I see that every few minutes I get Ack from the server, which causes it to remain open indefinitely. How do I turn off keep-Alive in go?
Thanks.
Upvotes: 2
Views: 6253
Reputation: 1328712
This was mentioned in 2011 with issue 2011 (server side), and resolved in commit ac213ab.
That allows to set HTTP.Transport
configuration like DisableKeepAlives
to true, and MaxIdleConnsPerHost
to -1 and have those settings respected.
But implementing an Hijacker as in here is also an option if you need more control over the TCP connection.
Upvotes: 2