Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge does not automatically reconnect when initial connection attempt fails #2795

Open
EpicLPer opened this issue Apr 27, 2023 · 8 comments

Comments

@EpicLPer
Copy link

EpicLPer commented Apr 27, 2023

Heya!

I'm currently noticing a weird behavior from Mosquitto when it comes to bridging external MQTT brokers.
My current config bridges HiveMQ to Home Assistant's Mosquitto Add On, I've set everything up in mosquitto.conf and once it connects it works great, however at random times it either disconnects or doesn't connect at all when restarting Mosquitto. It also doesn't seem to try to connect after it initially failed, despite setting both keepalive_interval 20 and restart_timeout 20.
The log simply says Expiring client local.core-mosquitto.HiveMQ due to timeout, but never tries to reconnect to the broker again after that.

Is this expected behavior or am I onto something here? :) Thanks for the help!

Mosquitto Version: 2.0.15

@EpicLPer
Copy link
Author

Are there any updates on this?

@fbooij
Copy link

fbooij commented Jun 29, 2023

Today, I noticed the same issue, also with HiveMQ. Did you manage to fix this @EpicLPer?

@EpicLPer
Copy link
Author

Today, I noticed the same issue, also with HiveMQ. Did you manage to fix this @EpicLPer?

Sadly so far no permanent fix, tho if I ever have an extended period of time I'll switch to a better MQTT server due to this... not sure what I'll choose yet but the lack of updates makes this annoying tbh.

@fbooij
Copy link

fbooij commented Jul 1, 2023

I've made an automation that monitors the value of "$SYS/broker/connection/core-mosquitto.hivemq/state" and restarts the core-mosquitto addon until it returns 1. An ugly workaround but it works.

@ddokupil
Copy link

ddokupil commented Oct 3, 2023

Hi, Not sure if it's the same regression but I was trying to set my broker to act as a bridge in a way that if external broker isn't available still be able to handle local messages and try to reconnect every once in a while. And it fails like this:

Oct 03 08:25:34 NanoPi-NEO mosquitto[31381]: mosquitto: /build/mosquitto-iuNSqR/mosquitto-1.6.9/src/loop.c:730: loop_handle_reads_writes: Assertion `pollfds[context->pollfd_index].fd == context->sock' failed.
Oct 03 08:25:34 NanoPi-NEO systemd[1]: mosquitto.service: Main process exited, code=killed, status=6/ABRT
Oct 03 08:25:34 NanoPi-NEO systemd[1]: mosquitto.service: Failed with result 'signal'.
Oct 03 08:25:34 NanoPi-NEO systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 30.
Oct 03 08:25:34 NanoPi-NEO systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.

But I've got ver 1.6.9. Is it even possible to set it like I want to? Maybe you can suggest another version to try?

Edit: Never mind, updating to 2.0.18 fixed the issue.

@StafrGotar
Copy link

I can confirm that version 2.0.18 solved these kind of problems for me.

This was under Gentoo Linux where Mosquitto version 2.0.18 currently (Nov. 2023) is considered Test, indicated as ~2.0.18.

@vomov
Copy link

vomov commented Nov 20, 2023

2.0.18 appears to solve it for me as well.

@XANi
Copy link

XANi commented May 13, 2024

I get that under 2.0.18:

1714301814: Connecting bridge (step 2) dc1-mq (dc1-mq.example.com:1883)
1714301890: Outgoing messages are being dropped for client d2-core-mq1.dc1-mq.
1715431691: Expiring client local.d2-core-mq2.dc1-mq due to timeout.

config:

connection dc1-mq
address dc1-mq.example.com:1883 
bridge_protocol_version mqttv311
round_robin false

topic # both 1

remote_username bridge-user
remote_password pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants