-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goroutine leak #4061
Comments
@introspection3 I can’t reproduce this. Could you share more details, like the Gin version and your OS? |
Can not reproduce this, here is my output:
Environment: |
Can't reproduce. |
@appleboy sir,I resolved this by func GetRquestReturnBytes(url string) (body []byte, err error) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DisableKeepAlives: true, //by this
MaxIdleConnsPerHost: 14,
}
client := &http.Client{Transport: tr, Timeout: 7 * time.Second}
req, err := http.NewRequest("GET", url, nil)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36")
req.Header.Set("Content-Type", "application/json")
if err != nil {
return
}
resp, err := client.Do(req)
if err != nil {
return
}
defer resp.Body.Close()
defer client.CloseIdleConnections() //by this
body, err = io.ReadAll(resp.Body)
return
} |
you can delete two lines code |
How does this relate to gin with this code? If you want the problem to be solved, please provide a complete reproducible example related to gin |
Description
How to reproduce
Expectations
Actual result
Environment
The text was updated successfully, but these errors were encountered: