Skip to content
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

socket fd leaks if dial timeout occur #37

Open
trulyliu opened this issue Aug 29, 2018 · 4 comments
Open

socket fd leaks if dial timeout occur #37

trulyliu opened this issue Aug 29, 2018 · 4 comments

Comments

@trulyliu
Copy link

trulyliu commented Aug 29, 2018

req, err := http.NewRequest("POST", s.url, buffer)
if err != nil {
	return err
}
if s.auth != nil {
	req.SetBasicAuth(s.auth.Login, s.auth.Password)
}

req.Header.Add("Content-Type", "text/xml; charset=\"utf-8\"")
req.Header.Add("SOAPAction", soapAction)
req.Header.Set("User-Agent", "gowsdl/0.1")
req.Close = true

tr := &http.Transport{
	TLSClientConfig: &tls.Config{
		InsecureSkipVerify: s.tls,
	},
	Dial: (&net.Dialer{
		Timeout:   60 * time.Second,
		KeepAlive: 10 * time.Second,
	}).Dial,
	TLSHandshakeTimeout:   5 * time.Second,
	ResponseHeaderTimeout: 300 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
}

client := &http.Client{Transport: tr}
reliableClient := pester.NewExtendedClient(client)
res, err := reliableClient.Do(req)
if nil != res && nil != res.Body {
	defer res.Body.Close()
}
if err != nil {
	return err
}

If dial timeout occur, opened socket fd will leak.
sudo lsof -n -a -p $(pidof processname) |grep "can't identify protocol" |wc -l
You will see many 'can't identify protocol' socket.

@sethgrid
Copy link
Owner

Thanks for submitting this! I wont have time to dig in this week (PRs welcome!). I can try to dig in this weekend or the next, luck willing.

@sethgrid
Copy link
Owner

I've been moving across the country and am super bogged down. I've not forgotten about this, but I don't know when I can get to it. PRs welcome!

@Maelkum
Copy link

Maelkum commented Aug 10, 2020

Can this still be reproduced? I experimented with dial timeouts on ubuntu today and couldn't reproduce leaked sockets.

@sethgrid
Copy link
Owner

sethgrid commented Aug 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants