{"action":"created","issue":{"url":"https://api.github.com/repos/olivere/elastic/issues/107","labels_url":"https://api.github.com/repos/olivere/elastic/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/olivere/elastic/issues/107/comments","events_url":"https://api.github.com/repos/olivere/elastic/issues/107/events","html_url":"https://github.com/olivere/elastic/issues/107","id":97353730,"number":107,"title":"close connections","user":{"login":"baxterbln","id":7488670,"avatar_url":"https://avatars.githubusercontent.com/u/7488670?v=3","gravatar_id":"","url":"https://api.github.com/users/baxterbln","html_url":"https://github.com/baxterbln","followers_url":"https://api.github.com/users/baxterbln/followers","following_url":"https://api.github.com/users/baxterbln/following{/other_user}","gists_url":"https://api.github.com/users/baxterbln/gists{/gist_id}","starred_url":"https://api.github.com/users/baxterbln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxterbln/subscriptions","organizations_url":"https://api.github.com/users/baxterbln/orgs","repos_url":"https://api.github.com/users/baxterbln/repos","events_url":"https://api.github.com/users/baxterbln/events{/privacy}","received_events_url":"https://api.github.com/users/baxterbln/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-26T22:04:58Z","updated_at":"2015-07-27T06:20:38Z","closed_at":null,"body":"Hello,\r\n\r\nin the moment we testing your really nice package on our application but we had a problem with the open connections to the elasticserver. After benchmarks test or in our testing environment we had a lot open (zombie) connections with TIME_WAIT. \r\n\r\nlsof -p say:\r\nserver  24086 root  276u  sock      0,7      0t0 63140932 can't identify protocol\r\n\r\nnetstat -an -p tcp\r\ntcp        0      0 XXXXX:59824    XXX:9200         TIME_WAIT   -\r\n\r\nOur connection func is:\r\n\r\nfunc NewElasticSession() *elastic.Client {\r\n\t       \r\n\thttpClient := &http.Client{\r\n\t\tTransport: &BasicAuthTransport{\r\n\t\t\tusername:  ReadIniString(\"elastic user\"),\r\n\t\t\tpassword:  ReadIniString(\"elastic pass\"),\r\n\t\t},\r\n\t}\r\n\t\r\n        elastic.SetTraceLog(log.New(os.Stdout, \"\", log.LstdFlags))\r\n        elastic.SetInfoLog(log.New(os.Stdout, \"\", log.LstdFlags))\r\n        client, err := elastic.NewClient(\r\n                elastic.SetHttpClient(httpClient),\r\n                elastic.SetURL(elasticServer),\r\n                elastic.SetSniff(true),\r\n\t\telastic.SetHealthcheckInterval(10*time.Second),\r\n\t\telastic.SetMaxRetries(5),\r\n\t\telastic.SetErrorLog(log.New(os.Stderr, \"ELASTIC \", log.LstdFlags)),\r\n\t\telastic.SetInfoLog(log.New(os.Stdout, \"\", log.LstdFlags)))\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\texists, err := client.IndexExists(index).Do()\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tif !exists {\r\n\t\t_, err := client.CreateIndex(index).Do()\r\n\t\tif err != nil {\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\t}\r\n\r\n\treturn client\r\n}"},"comment":{"url":"https://api.github.com/repos/olivere/elastic/issues/comments/125100192","html_url":"https://github.com/olivere/elastic/issues/107#issuecomment-125100192","issue_url":"https://api.github.com/repos/olivere/elastic/issues/107","id":125100192,"user":{"login":"olivere","id":134848,"avatar_url":"https://avatars.githubusercontent.com/u/134848?v=3","gravatar_id":"","url":"https://api.github.com/users/olivere","html_url":"https://github.com/olivere","followers_url":"https://api.github.com/users/olivere/followers","following_url":"https://api.github.com/users/olivere/following{/other_user}","gists_url":"https://api.github.com/users/olivere/gists{/gist_id}","starred_url":"https://api.github.com/users/olivere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivere/subscriptions","organizations_url":"https://api.github.com/users/olivere/orgs","repos_url":"https://api.github.com/users/olivere/repos","events_url":"https://api.github.com/users/olivere/events{/privacy}","received_events_url":"https://api.github.com/users/olivere/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T06:20:38Z","updated_at":"2015-07-27T06:20:38Z","body":"Hi there! Hmm, I've been using Elastic on server processes for months and I've never come up with that. But your method name got my curious... Do you perhaps create one connection per session? You should really create just one (or a handful) client per app and share it."}}