Open canique opened 3 years ago
The problem does not occur when bridge protocol v50 is used. The initial received publish has the retain flag set and there is no ping pong between Mosquitto and the remote broker.
Does HiveMQ definitely support the non-standard v3 bridge protocol, because if not then what should happen is that the bridge will initially try to connect with the bridge protocol, but when it fails will reconnect as a standard client. Connecting as a standard client means that the retain bit operates as normal. That is to say, the retained bit will only be set when a client receives messages that are "stale" - i.e. immediately on subscribe. Subsequent messages received are effectively straight from the client and are fresh, so the retained bit is not set. That matches the snippets of your logs. You would be able to see more clearly by looking at the initial bridge connection to the remote broker.
My mosquitto bridge (v2.0.11) is setup with TLSv1.3 and mqttv31 bridge protocol.
I have a topic setup as inbound+outbound, with QoS 1 and a remote-prefix. If I publish a message with QoS 1, and retain flag set on the remote broker (HiveMQ), it forwards the message to Mosquitto. The client connected to mosquitto sees the message - so far so good. But as soon as the client reconnects (with a new client ID, and new subscription), it does not receive the message although the message had its retain flag set.
Peculiarly enough, after a restart of Mosquitto the message that was missing is now sent to new clients.
The log file looks like this when sending the first publish msg with retain flag set via the remote broker:
So, the retain flag seems to be 0 here...
After a restart of Mosquitto the log file looks like this.
I think what's happening here is:
So it's kind of a ping-pong (configuration issue). The interesting point is: Mosquitto initially does not get the incoming msg with retain flag set on a persistent bridge connection. Mosquitto is probably seen as a normal client to the remote broker. Normal clients get messages without the retain flag set, unless it's a new subscription.
Is there any configuration parameter that forces the retain flag to be set with MQTTv31? I'd love to use v5 but the bug @ https://github.com/eclipse/mosquitto/issues/2248 prevents me from doing so.