Skip to content
Snippets Groups Projects
Commit 3d62e045 authored by Daniel Nelson's avatar Daniel Nelson Committed by GitHub
Browse files

Fix format of connection_timeout in mqtt_consumer (#3286)

parent ad4a5aa7
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ The plugin expects messages in the ...@@ -14,7 +14,7 @@ The plugin expects messages in the
## MQTT QoS, must be 0, 1, or 2 ## MQTT QoS, must be 0, 1, or 2
qos = 0 qos = 0
## Connection timeout for initial connection in seconds ## Connection timeout for initial connection in seconds
connection_timeout = 30 connection_timeout = "30s"
## Topics to subscribe to ## Topics to subscribe to
topics = [ topics = [
......
...@@ -15,6 +15,9 @@ import ( ...@@ -15,6 +15,9 @@ import (
"github.com/eclipse/paho.mqtt.golang" "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 { type MQTTConsumer struct {
Servers []string Servers []string
Topics []string Topics []string
...@@ -57,7 +60,7 @@ var sampleConfig = ` ...@@ -57,7 +60,7 @@ var sampleConfig = `
## MQTT QoS, must be 0, 1, or 2 ## MQTT QoS, must be 0, 1, or 2
qos = 0 qos = 0
## Connection timeout for initial connection in seconds ## Connection timeout for initial connection in seconds
connection_timeout = 30 connection_timeout = "30s"
## Topics to subscribe to ## Topics to subscribe to
topics = [ topics = [
...@@ -270,6 +273,8 @@ func (m *MQTTConsumer) createOpts() (*mqtt.ClientOptions, error) { ...@@ -270,6 +273,8 @@ func (m *MQTTConsumer) createOpts() (*mqtt.ClientOptions, error) {
func init() { func init() {
inputs.Add("mqtt_consumer", func() telegraf.Input { inputs.Add("mqtt_consumer", func() telegraf.Input {
return &MQTTConsumer{} return &MQTTConsumer{
ConnectionTimeout: defaultConnectionTimeout,
}
}) })
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment