You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mosquitto version: 2.0.15
system: Linux kernel 3.4.40
Hi,
I use libmosquitto as MQTT client. One day, I found MQTT connection lost, I checked log that recorded a few reconnection events, but it stopped to reconnect with Unable to connect (Lookup error.)
In log, there is a strange scenario: the app try to subscribe topic, this is invoked in on_connect callback, subscribe fails with code 4(MOSQ_ERR_NO_CONN)
I'm using these APIs:
MQTT_PROTOCOL_V311
mosquitto_connect_bind_async
mosquitto_loop_start
mosquitto_connect_v5_callback_set
mosquitto_subscribe_v5_callback_set
mosquitto_message_v5_callback_set
mosquitto_disconnect_v5_callback_set
mosquitto_publish_v5_callback_set
Any suggestion is appreciated, thanks!
The text was updated successfully, but these errors were encountered:
Hi,
Libmosquitto has some return codes (MOSQ_ERR_<code>) that are considered fatal errors and once happened will stop the automatic reconnection and your client application should 'manually' request to connect again.
One of these fatal errors is the MOSQ_ERR_EAI (Lookup error), that indicates the mosquitto wasn't able to resolve the DNS to connect to your broker host. That said, your application should request a new connection.
As the error of MOSQ_ERR_EAI happened, it means your application is not connected to the broker and any subscribe/publish will fail due not having a connection to the broker (rc MOSQ_ERR_NO_CONN).
Note that on the on connect callback, your application should check if the return code received is MOSQ_ERR_SUCCESS and if yes then it is fine, but if it is any other MOSQ_ERR_<code> (like your case MOSQ_ERR_EAI), the application should do a new mosquitto_connect_bind_async and mosquitto_loop_start.
Mosquitto fatal return code errors are:
MOSQ_ERR_NOMEM
MOSQ_ERR_PROTOCOL:
MOSQ_ERR_INVAL:
MOSQ_ERR_NOT_FOUND:
MOSQ_ERR_TLS:
MOSQ_ERR_PAYLOAD_SIZE:
MOSQ_ERR_NOT_SUPPORTED:
MOSQ_ERR_AUTH:
MOSQ_ERR_ACL_DENIED:
MOSQ_ERR_UNKNOWN:
MOSQ_ERR_EAI:
MOSQ_ERR_PROXY:
But for any rc, if a errno EPROTO happened, it will also exit the main loop and you should ask for a new connection (not much programmatic, you see)
mosquitto version: 2.0.15
system: Linux kernel 3.4.40
Hi,
I use libmosquitto as MQTT client. One day, I found MQTT connection lost, I checked log that recorded a few reconnection events, but it stopped to reconnect with Unable to connect (Lookup error.)
In log, there is a strange scenario: the app try to subscribe topic, this is invoked in on_connect callback, subscribe fails with code 4(MOSQ_ERR_NO_CONN)
I'm using these APIs:
MQTT_PROTOCOL_V311
mosquitto_connect_bind_async
mosquitto_loop_start
mosquitto_connect_v5_callback_set
mosquitto_subscribe_v5_callback_set
mosquitto_message_v5_callback_set
mosquitto_disconnect_v5_callback_set
mosquitto_publish_v5_callback_set
Any suggestion is appreciated, thanks!
The text was updated successfully, but these errors were encountered: