File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 101
101
// The interval (in seconds) in which the client will send a ping to the broker,
102
102
// if no other message has been sent.
103
103
'keep_alive_interval ' => env ('MQTT_KEEP_ALIVE_INTERVAL ' , 10 ),
104
+
105
+ // Additional settings for the optional auto-reconnect. The delay between reconnect attempts is in seconds.
106
+ 'auto_reconnect ' => [
107
+ 'enabled ' => env ('MQTT_AUTO_RECONNECT_ENABLED ' , false ),
108
+ 'max_reconnect_attempts ' => env ('MQTT_AUTO_RECONNECT_MAX_RECONNECT_ATTEMPTS ' , 3 ),
109
+ 'delay_between_reconnect_attempts ' => env ('MQTT_AUTO_RECONNECT_DELAY_BETWEEN_RECONNECT_ATTEMPTS ' , 0 ),
110
+ ],
111
+
104
112
],
105
113
106
114
],
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ protected function buildConnectionSettings(array $config): ConnectionSettings
177
177
->setLastWillTopic (Arr::get ($ config , 'last_will.topic ' ))
178
178
->setLastWillMessage (Arr::get ($ config , 'last_will.message ' ))
179
179
->setLastWillQualityOfService ((int ) Arr::get ($ config , 'last_will.quality_of_service ' , MqttClient::QOS_AT_MOST_ONCE ))
180
- ->setRetainLastWill ((bool ) Arr::get ($ config , 'last_will.retain ' , false ));
180
+ ->setRetainLastWill ((bool ) Arr::get ($ config , 'last_will.retain ' , false ))
181
+ ->setReconnectAutomatically ((bool ) Arr::get ($ config , 'auto_reconnect.enabled ' , false ))
182
+ ->setMaxReconnectAttempts ((int ) Arr::get ($ config , 'auto_reconnect.max_reconnect_attempts ' , 3 ))
183
+ ->setDelayBetweenReconnectAttempts ((int ) Arr::get ($ config , 'auto_reconnect.delay_between_reconnect_attempts ' , 0 ));
181
184
}
182
185
}
You can’t perform that action at this time.
0 commit comments