Skip to content

Commit

Permalink
Limit wait time for writes in mqtt output (influxdata#3699)
Browse files Browse the repository at this point in the history
(cherry picked from commit 91fc276)
  • Loading branch information
danielnelson authored and charless-splunk committed Jun 19, 2018
1 parent c09c96e commit 5432627
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/outputs/mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var sampleConfig = `
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
## Timeout for write operations. default: 5s
# timeout = "5s"
## client ID, if not set a random ID is generated
# client_id = ""
Expand Down Expand Up @@ -191,6 +194,11 @@ func (m *MQTT) createOpts() (*paho.ClientOptions, error) {
}
opts.WriteTimeout = m.Timeout.Duration

if m.Timeout.Duration < time.Second {
m.Timeout.Duration = 5 * time.Second
}
opts.WriteTimeout = m.Timeout.Duration

if m.ClientID != "" {
opts.SetClientID(m.ClientID)
} else {
Expand Down

0 comments on commit 5432627

Please sign in to comment.