summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mqtt.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/mqtt.go b/mqtt.go
index 63e5042..5c1b1ad 100644
--- a/mqtt.go
+++ b/mqtt.go
@@ -15,6 +15,7 @@ const (
RETAINED = true
MQTT_CONNECT_TIMEOUT = 1 * time.Second
MQTT_DISCONNECT_TIMEOUT_US = 500
+ MQTT_KEEPALIVE_PERIOD = 2 * time.Second
)
type MQTTMessage struct {
@@ -32,6 +33,7 @@ func MQTTRun(tx chan MQTTMessage) {
opts.SetAutoReconnect(true)
opts.SetConnectRetry(true)
opts.SetConnectTimeout(MQTT_CONNECT_TIMEOUT)
+ opts.SetKeepAlive(MQTT_KEEPALIVE_PERIOD)
client := mqtt.NewClient(opts)