重连选项设置:
int mosquitto_reconnect_delay_set(struct mosquitto *mosq, unsigned int reconnect_delay, unsigned int reconnect_delay_max, bool reconnect_exponential_backoff);
可设置重连延时时间,包含两种模式:
(1)固定延时发起重连请求
(2)按照设定的起止时间以及间隔时间,发起重连请求(这一套逻辑更加符合实际项目开发)
* Example 1:
* delay=2, delay_max=10, exponential_backoff=False
* Delays would be: 2, 4, 6, 8, 10, 10, ...
*
* Example 2:
* delay=3, delay_max=30, exponential_backoff=True
* Delays would be: 3, 6, 12, 24, 30, 30, ...
8、mosquito退出和库相关资源释放
int mosquitto_lib_cleanup(void);