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 101101 // The interval (in seconds) in which the client will send a ping to the broker,
102102 // if no other message has been sent.
103103 '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+
104112 ],
105113
106114 ],
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ protected function buildConnectionSettings(array $config): ConnectionSettings
177177 ->setLastWillTopic (Arr::get ($ config , 'last_will.topic ' ))
178178 ->setLastWillMessage (Arr::get ($ config , 'last_will.message ' ))
179179 ->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 ));
181184 }
182185}
You can’t perform that action at this time.
0 commit comments