eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.1k stars 2.4k forks source link

Settting `per_listener_settings` to `true` prevents resuming communications #2806

Open datafoo opened 1 year ago

datafoo commented 1 year ago

Consider these 2 simple configuration files:

mosquitto-1.conf:

per_listener_settings false
listener 1883
allow_anonymous true

mosquitto-2.conf:

per_listener_settings true
listener 1883
allow_anonymous true

I ran the same test to verify conformance to [MQTT-3.1.2-4] and [MQTT-3.1.2-5] with each of the 2 configuration files:

  1. From client A, connect with CleanSession is set to 0
  2. From client B, connect with CleanSession is set to 0
  3. From client B, subscribe to topic filter # with QoS 2
  4. From client A, publish the Application Message 1 on topic light with QoS 2
  5. From client B, notice the reception of Application Message 1 on topic light
  6. From client B, disconnect
  7. From client A, publish the Application Message 2 on topic light with QoS 2
  8. From client B, connect with CleanSession is set to 0
  9. From client B, notice the reception of Application Message 2 on topic light

With mosquitto-1.conf, the test was successful:

PS C:\Program Files\Mosquitto> .\mosquitto.exe -v -c .\mosquitto-1.conf
1683723015: mosquitto version 2.0.15 starting
1683723015: Config loaded from .\mosquitto-1.conf.
1683723015: Opening ipv6 listen socket on port 1883.
1683723015: Opening ipv4 listen socket on port 1883.
1683723015: mosquitto version 2.0.15 running
1683723045: New connection from 127.0.0.1:51208 on port 1883.
1683723045: New client connected from 127.0.0.1:51208 as 9f9144b8289248f895a4983261202b1b (p2, c0, k60).
1683723045: No will message specified.
1683723045: Sending CONNACK to 9f9144b8289248f895a4983261202b1b (0, 0)
1683723064: New connection from 127.0.0.1:51209 on port 1883.
1683723064: New client connected from 127.0.0.1:51209 as mqttx_a57b0190 (p2, c0, k60).
1683723064: No will message specified.
1683723064: Sending CONNACK to mqttx_a57b0190 (0, 0)
1683723064: Received SUBSCRIBE from mqttx_a57b0190
1683723064:     # (QoS 2)
1683723064: mqttx_a57b0190 2 #
1683723064: Sending SUBACK to mqttx_a57b0190
1683723096: Received PUBLISH from 9f9144b8289248f895a4983261202b1b (d0, q2, r0, m1, 'light', ... (1 bytes))
1683723096: Sending PUBREC to 9f9144b8289248f895a4983261202b1b (m1, rc0)
1683723096: Received PUBREL from 9f9144b8289248f895a4983261202b1b (Mid: 1)
1683723096: Sending PUBLISH to mqttx_a57b0190 (d0, q2, r0, m1, 'light', ... (1 bytes))
1683723096: Sending PUBCOMP to 9f9144b8289248f895a4983261202b1b (m1)
1683723096: Received PUBREC from mqttx_a57b0190 (Mid: 1)
1683723096: Sending PUBREL to mqttx_a57b0190 (m1)
1683723096: Received PUBCOMP from mqttx_a57b0190 (Mid: 1, RC:0)
1683723102: Received DISCONNECT from mqttx_a57b0190
1683723102: Client mqttx_a57b0190 disconnected.
1683723107: Received PUBLISH from 9f9144b8289248f895a4983261202b1b (d0, q2, r0, m2, 'light', ... (1 bytes))
1683723107: Sending PUBREC to 9f9144b8289248f895a4983261202b1b (m2, rc0)
1683723107: Received PUBREL from 9f9144b8289248f895a4983261202b1b (Mid: 2)
1683723107: Sending PUBCOMP to 9f9144b8289248f895a4983261202b1b (m2)
1683723110: New connection from 127.0.0.1:51210 on port 1883.
1683723110: New client connected from 127.0.0.1:51210 as mqttx_a57b0190 (p2, c0, k60).
1683723110: No will message specified.
1683723110: Sending CONNACK to mqttx_a57b0190 (1, 0)
1683723110: Sending PUBLISH to mqttx_a57b0190 (d0, q2, r0, m2, 'light', ... (1 bytes))
1683723110: Received PUBREC from mqttx_a57b0190 (Mid: 2)
1683723110: Sending PUBREL to mqttx_a57b0190 (m2)
1683723110: Received PUBCOMP from mqttx_a57b0190 (Mid: 2, RC:0)
1683723110: Received SUBSCRIBE from mqttx_a57b0190
1683723110:     # (QoS 2)
1683723110: mqttx_a57b0190 2 #
1683723110: Sending SUBACK to mqttx_a57b0190
1683723122: mosquitto version 2.0.15 terminating

With mosquitto-2.conf, the test was not successful:

PS C:\Program Files\Mosquitto> .\mosquitto.exe -v -c .\mosquitto-2.conf
1683723157: mosquitto version 2.0.15 starting
1683723157: Config loaded from .\mosquitto-2.conf.
1683723157: Opening ipv6 listen socket on port 1883.
1683723157: Opening ipv4 listen socket on port 1883.
1683723157: mosquitto version 2.0.15 running
1683723159: New connection from 127.0.0.1:51214 on port 1883.
1683723159: New client connected from 127.0.0.1:51214 as db272b0d10cd46bba96b7c4360e6e3f9 (p2, c0, k60).
1683723159: No will message specified.
1683723159: Sending CONNACK to db272b0d10cd46bba96b7c4360e6e3f9 (0, 0)
1683723169: New connection from 127.0.0.1:51215 on port 1883.
1683723169: New client connected from 127.0.0.1:51215 as mqttx_ee97ba09 (p2, c0, k60).
1683723169: No will message specified.
1683723169: Sending CONNACK to mqttx_ee97ba09 (0, 0)
1683723170: Received SUBSCRIBE from mqttx_ee97ba09
1683723170:     # (QoS 2)
1683723170: mqttx_ee97ba09 2 #
1683723170: Sending SUBACK to mqttx_ee97ba09
1683723175: Received PUBLISH from db272b0d10cd46bba96b7c4360e6e3f9 (d0, q2, r0, m1, 'light', ... (1 bytes))
1683723175: Sending PUBREC to db272b0d10cd46bba96b7c4360e6e3f9 (m1, rc0)
1683723175: Received PUBREL from db272b0d10cd46bba96b7c4360e6e3f9 (Mid: 1)
1683723175: Sending PUBLISH to mqttx_ee97ba09 (d0, q2, r0, m1, 'light', ... (1 bytes))
1683723175: Sending PUBCOMP to db272b0d10cd46bba96b7c4360e6e3f9 (m1)
1683723175: Received PUBREC from mqttx_ee97ba09 (Mid: 1)
1683723175: Sending PUBREL to mqttx_ee97ba09 (m1)
1683723175: Received PUBCOMP from mqttx_ee97ba09 (Mid: 1, RC:0)
1683723179: Received DISCONNECT from mqttx_ee97ba09
1683723179: Client mqttx_ee97ba09 disconnected.
1683723182: Received PUBLISH from db272b0d10cd46bba96b7c4360e6e3f9 (d0, q2, r0, m2, 'light', ... (1 bytes))
1683723182: Sending PUBREC to db272b0d10cd46bba96b7c4360e6e3f9 (m2, rc0)
1683723182: Received PUBREL from db272b0d10cd46bba96b7c4360e6e3f9 (Mid: 2)
1683723182: Sending PUBCOMP to db272b0d10cd46bba96b7c4360e6e3f9 (m2)
1683723186: New connection from 127.0.0.1:51216 on port 1883.
1683723186: New client connected from 127.0.0.1:51216 as mqttx_ee97ba09 (p2, c0, k60).
1683723186: No will message specified.
1683723186: Sending CONNACK to mqttx_ee97ba09 (1, 0)
1683723186: Received SUBSCRIBE from mqttx_ee97ba09
1683723186:     # (QoS 2)
1683723186: mqttx_ee97ba09 2 #
1683723186: Sending SUBACK to mqttx_ee97ba09
1683723191: mosquitto version 2.0.15 terminating

The step 9 of the test was not validated, the Application Message 2 on topic light was not received on client B.

pat1 commented 1 year ago

duplicated of #2618