mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

MQTT bridge retries stall local messages

Open damanuel opened this issue 2 months ago • 2 comments

I have a broker with a bridge connection. When the connection to the bridge can't be established (out of wifi range), all incoming and outgoing messages will be stalled - also the ones going to local clients. After 5 seconds, they come in bursts. Another 5 seconds, it happens again.

2025-11-04T14:36:54: Connecting bridge central (my-url.com:8883)
2025-11-04T14:36:54: Error creating bridge: Try again.
2025-11-04T14:36:59: Received PUBLISH from edge_client (d0, q0, r1, m0, 'event/state', ... (591 bytes))
2025-11-04T14:36:59: Received SUBSCRIBE from mqttjs_474bd637
2025-11-04T14:36:59:    response/joystick_command/7d186262-2775-44c8-93fe-83cfa6ebdb22 (QoS 0)
2025-11-04T14:36:59: mqttjs_474bd637 0 response/joystick_command/7d186262-2775-44c8-93fe-83cfa6ebdb22
2025-11-04T14:36:59: Sending SUBACK to mqttjs_474bd637
2025-11-04T14:36:59: Received PUBLISH from mqttjs_474bd637 (d0, q0, r0, m0, 'request/joystick_command/7d186262-2775-44c8-93fe-83cfa6ebdb22', ... (12 bytes))
2025-11-04T14:36:59: Sending PUBLISH to edge_client (d0, q0, r0, m0, 'request/joystick_command/7d186262-2775-44c8-93fe-83cfa6ebdb22', ... (12 bytes))

Unofortunately, this stalls joystick commands (among others) coming from a local client - even though the local connection is just fine.

Is there something from a configuration point of view that can be done?

The current configuration looks like this:

listener 1883
allow_anonymous true

listener 9001
protocol websockets
allow_anonymous true

# General settings for the broker
max_queued_messages 500000
max_inflight_messages 1
persistence true
persistence_location /mosquitto/data
persistent_client_expiration 30d
autosave_interval 60

# Log settings
log_type all
log_timestamp_format %Y-%m-%dT%H:%M:%S

# Bridge settings
connection central
address my-url.com:8883
topic event/mission out 2 "" box/
bridge_protocol_version mqttv50
remote_clientid box

# bridge cert auth
bridge_cafile /mosquitto/credentials/ca.crt
bridge_certfile /mosquitto/credentials/client.crt
bridge_keyfile /mosquitto/credentials/client.pem


# Bridge retry intervals (to handle unreliable networks)
cleansession false
start_type automatic
keepalive_interval 60
restart_timeout 300

damanuel avatar Nov 04 '25 16:11 damanuel

The issue seems to be blocking blocking name resolution. It works fine when I add the name to my hosts file.

I want to compileWITH_ADNS and create a docker image - this might solve my issue. It seems that the docker images are alpine based and don't have glibc, so the flag is hardcoded to 'NO'.

Is there a straightforward way to build a docker image with ADNS endabled? Would this potentially solve that problem?

damanuel avatar Nov 05 '25 10:11 damanuel

Using a docker image with the ADNS flag fixed this for us. Since it's only available in glibc, I had to use a non-alpine base image (I used debian). Would it make sense to add a docker recipe plus a tag for that?

damanuel avatar Nov 12 '25 08:11 damanuel