Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format of connection_timeout in mqtt_consumer #3286

Merged
merged 1 commit into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/inputs/mqtt_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The plugin expects messages in the
## MQTT QoS, must be 0, 1, or 2
qos = 0
## Connection timeout for initial connection in seconds
connection_timeout = 30
connection_timeout = "30s"

## Topics to subscribe to
topics = [
Expand Down
9 changes: 7 additions & 2 deletions plugins/inputs/mqtt_consumer/mqtt_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
"github.com/eclipse/paho.mqtt.golang"
)

// 30 Seconds is the default used by paho.mqtt.golang
var defaultConnectionTimeout = internal.Duration{Duration: 30 * time.Second}

type MQTTConsumer struct {
Servers []string
Topics []string
Expand Down Expand Up @@ -57,7 +60,7 @@ var sampleConfig = `
## MQTT QoS, must be 0, 1, or 2
qos = 0
## Connection timeout for initial connection in seconds
connection_timeout = 30
connection_timeout = "30s"

## Topics to subscribe to
topics = [
Expand Down Expand Up @@ -270,6 +273,8 @@ func (m *MQTTConsumer) createOpts() (*mqtt.ClientOptions, error) {

func init() {
inputs.Add("mqtt_consumer", func() telegraf.Input {
return &MQTTConsumer{}
return &MQTTConsumer{
ConnectionTimeout: defaultConnectionTimeout,
}
})
}