mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

LWT not send on multiple connects

Open phbasler opened this issue 3 years ago • 2 comments

Starting with v2.0.11 (and still present in 2.0.14), the following problem occurs:

  • Connect a Client which subscribes to "#"
  • Connect a second Client with a set Will, the output is registered correctly in verbose mode
  • Send another connect message from the second Client. The verbose mode lists protocol error due to multiple connect messages but the Will is not send to the first client.

The verbose output for 2.0.11 is

mosquitto    | 1654009794: mosquitto version 2.0.11 starting
mosquitto    | 1654009794: Config loaded from /mosquitto/config/mosquitto.conf.
mosquitto    | 1654009794: Opening ipv4 listen socket on port 1883.
mosquitto    | 1654009794: Opening ipv6 listen socket on port 1883.
mosquitto    | 1654009794: Opening websockets listen socket on port 9001.
mosquitto    | 1654009794: mosquitto version 2.0.11 running
mosquitto    | 1654009826: New client connected from ::ffff:172.19.0.1:42752 as FeedbackClient (p2, c1, k600).
mosquitto    | 1654009826: No will message specified.
mosquitto    | 1654009826: Sending CONNACK to FeedbackClient (0, 0)
mosquitto    | 1654009826: Received SUBSCRIBE from FeedbackClient
mosquitto    | 1654009826:      # (QoS 0)
mosquitto    | 1654009826: FeedbackClient 0 #
mosquitto    | 1654009826: Sending SUBACK to FeedbackClient
mosquitto    | 1654009826: New client connected from ::ffff:172.19.0.1:42756 as LWTClient (p2, c1, k600).
mosquitto    | 1654009826: Will message specified (12 bytes) (r0, q0).
mosquitto    | 1654009826:      LWT/TestLWT
mosquitto    | 1654009826: Sending CONNACK to LWTClient (0, 0)
mosquitto    | 1654009826: Bad client LWTClient sending multiple CONNECT messages.
mosquitto    | 1654009826: Client LWTClient closed its connection.
mosquitto    | 1654009831: Received DISCONNECT from FeedbackClient
mosquitto    | 1654009831: Client FeedbackClient disconnected.

For v2.0.10 the same output is

mosquitto    | 1654009946: mosquitto version 2.0.10 starting
mosquitto    | 1654009946: Config loaded from /mosquitto/config/mosquitto.conf.
mosquitto    | 1654009946: Opening ipv4 listen socket on port 1883.
mosquitto    | 1654009946: Opening ipv6 listen socket on port 1883.
mosquitto    | 1654009946: Opening websockets listen socket on port 9001.
mosquitto    | 1654009946: mosquitto version 2.0.10 running
mosquitto    | 1654009950: New client connected from ::ffff:172.19.0.1:42760 as FeedbackClient (p2, c1, k600).
mosquitto    | 1654009950: No will message specified.
mosquitto    | 1654009950: Sending CONNACK to FeedbackClient (0, 0)
mosquitto    | 1654009950: Received SUBSCRIBE from FeedbackClient
mosquitto    | 1654009950:      # (QoS 0)
mosquitto    | 1654009950: FeedbackClient 0 #
mosquitto    | 1654009950: Sending SUBACK to FeedbackClient
mosquitto    | 1654009950: New client connected from ::ffff:172.19.0.1:42764 as LWTClient (p2, c1, k600).
mosquitto    | 1654009950: Will message specified (12 bytes) (r0, q0).
mosquitto    | 1654009950:      LWT/TestLWT
mosquitto    | 1654009950: Sending CONNACK to LWTClient (0, 0)
mosquitto    | 1654009950: Bad client LWTClient sending multiple CONNECT messages.
mosquitto    | 1654009950: Client LWTClient closed its connection.
mosquitto    | 1654009950: Sending PUBLISH to FeedbackClient (d0, q0, r0, m0, 'LWT/TestLWT', ... (12 bytes))
mosquitto    | 1654009951: Received DISCONNECT from FeedbackClient
mosquitto    | 1654009951: Client FeedbackClient disconnected.

phbasler avatar May 31 '22 15:05 phbasler

Hmmm, I can see what is happening here but I'm not sure what the correct response is. I'm still thinking about the correct response. One way of looking at it could be that a malicious client shouldn't be trusted and so the will shouldn't be sent.

ralight avatar Jun 03 '22 23:06 ralight

@ralight This is actually covered by the spec in [MQTT-3.1.0-2]. There it says

"The Server MUST process a second CONNECT Packet sent from a Client as a protocol violation and disconnect the Client."

According to [MQTT-3.1.2-8] a protocol error should always leed to the publication of the Will message.

phbasler avatar Jun 05 '22 23:06 phbasler