Skip to content

Commit

Permalink
feat: fill more http transport parameters in inputs/burrow plugin
Browse files Browse the repository at this point in the history
Default http.Transport doesn't setup dial timeout.
That leads to client stuck if for some reason there's no working
DNS or if server client connects to is stuck.

Explicitly configure dialer and other parameters.
  • Loading branch information
funny-falcon committed Mar 6, 2022
1 parent 2c2fcc4 commit 92742d2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions plugins/inputs/burrow/burrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package burrow
import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -218,11 +219,21 @@ func (b *burrow) createClient() (*http.Client, error) {
return nil, err
}

var transport http.Transport
timeout := time.Duration(b.ResponseTimeout)
transport.DialContext = (&net.Dialer{
Timeout: timeout,
DualStack: true,
}).DialContext
transport.TLSClientConfig = tlsCfg
transport.MaxIdleConnsPerHost = b.ConcurrentConnections / 2
transport.MaxConnsPerHost = b.ConcurrentConnections
transport.ResponseHeaderTimeout = timeout
transport.IdleConnTimeout = 90*time.Second

client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsCfg,
},
Timeout: time.Duration(b.ResponseTimeout),
Transport: &transport,
Timeout: timeout,
}

return client, nil
Expand Down

0 comments on commit 92742d2

Please sign in to comment.