Merge pull request #942 from influxdata/feature/fix-socket-leak

Fix influx querying to prevent leaking sockets
pull/10616/head
Chris Goller 2017-02-28 16:15:11 -06:00 committed by GitHub
commit c4ed5e3a18
2 changed files with 12 additions and 4 deletions

View File

@ -1,6 +1,7 @@
## v1.2.0 [unreleased]
### Bug Fixes
1. [#936](https://github.com/influxdata/chronograf/pull/936): Fix leaking sockets for InfluxQL queries
### Features

View File

@ -13,6 +13,14 @@ import (
var _ chronograf.TimeSeries = &Client{}
// Shared transports for all clients to prevent leaking connections
var (
skipVerifyTransport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
defaultTransport = &http.Transport{}
)
// Client is a device for retrieving time series data from an InfluxDB instance
type Client struct {
URL *url.URL
@ -74,10 +82,9 @@ func (c *Client) query(u *url.URL, q chronograf.Query) (chronograf.Response, err
hc := &http.Client{}
if c.InsecureSkipVerify {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
hc.Transport = tr
hc.Transport = skipVerifyTransport
} else {
hc.Transport = defaultTransport
}
resp, err := hc.Do(req)
if err != nil {