Hi I have a question about how to close an http connection explicitly?
My program is a server providing REST API and clients calls these API using golang net.http package.
The symptom is that I can observe in the server side /proc/<process_id>/fd directory, the socket handlers are increasing as the clients issues API calls, even the call is finished, the SOCKET fd will still be there. Thus the max limit will be reached before too long. I checked the client side code the resp is closed after each call as follows:
esp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// ...
My question is that if there is a way for the server to force to close the http connection to release the socket handlers?
thanks!
Wei