I built a web crawler that serves up some http info on its findings. The crawler runs as a go routine and martini runs the web server. After a while I start getting
2014/08/01 10:23:51 http: Accept error: accept tcp [::]:3000: too many open files; retrying in 1s.
I read I should try increasing the max open files only I am new to this level of configuration and have no idea how to do this. I am running this on Ubuntu 14.04. How do you change a martini servers max open files please and thank you.
Make sure you don't forget to close the response you get from an http.Get
, as in this issue.
This example shows a better response management:
resp, _ := http.Get("http://127.0.0.1:3000"+path)
s, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
If the issue really still persists, then you can try and increase the fs.file-max
in /etc/sysctl.conf
.
I solved this problem by moving the following code out side of the function:
var tr = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
var client = &http.Client{Transport: tr}