Here is my code https://goplay.space/#z5J6i_EPWmx
I want use the code to check the availability of the proxies
After set ulimit -n 256
and run for a while i got the error socket too many open files
ll /proc/$(ps aux|grep -v "grep"|grep './main'|awk '{print $2}'|head)/fd|grep -v '\.\.'|grep -v '\.'|wc -l
command output is 256, i check netstat there is many TIME_WAIT.
And i follow pprof, there is many goroutine more than queueChan
length, is it mean a new request was created before the request was completely closed , is it goroutine leak?
If remove http.Client Timeout and keep transport.Dial Timeout, TIME_WAIT will be decreased,but ESTABLISHED is incresed and request does not finished when dial timeout is execed
My question is:
- how can i close connection immediately when the request timeout?
- different host of proxy can reuse connections?