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

Using the `mosquitto_sub -R` flag causes failed subscription. #1353

Closed
benbarbour opened this issue Jul 18, 2019 · 2 comments

Comments

@benbarbour
Copy link

commented Jul 18, 2019

I'm running mosquitto 1.6.3 and if I run mosquitto_sub -t root/A/B/C -C 1 -W 5 -u usr1 -P usr1Pwd -I ben -d and then before it times out I run mosquitto_pub -t root/A/B/C -m hello -u usr2 -P usr2Pwd then I get this output (after creating the given users, of course):

mosquitto_sub output

Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 1, Topic: root/A/B/C, QoS: 0, Options: 0x00)
Client ben1 received SUBACK
Subscribed (mid: 1): 0
Client ben1 received PUBLISH (d0, q0, r0, m0, 'root/A/B/C', ... (5 bytes))
hello
Client ben1 sending DISCONNECT

Broker logs

1563484048: New connection from 10.0.0.112 on port 1883.
1563484049: New client connected from 10.0.0.112 as ben1 (p2, c1, k60, u'usr1').
1563484050: New connection from 10.0.0.113 on port 1883.
1563484050: New client connected from 10.0.0.113 as mosq/mgwUWpjT8tcFTk5dbZ (p2, c1, k60, u'usr2').
1563484050: Client ben1 disconnected.
1563484050: Client mosq/mgwUWpjT8tcFTk5dbZ disconnected.

However, if I retry the same thing with the subscribe command changed to: mosquitto_sub -t root/A/B/C -C 1 -W 5 -u usr1 -P usr1Pwd -I ben -d -R (just add the -R flag) then this is the output:

mosquitto_sub output

Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 1, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 2, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 3, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 4, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 5, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 6, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 7, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 8, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 9, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 10, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 11, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 12, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 13, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 14, Topic: root/A/B/C, QoS: 0, Options: 0x20)
Client ben1 sending CONNECT
Client ben1 received CONNACK (0)
Client ben1 sending SUBSCRIBE (Mid: 15, Topic: root/A/B/C, QoS: 0, Options: 0x20)

Broker logs

1563484353: New connection from 10.0.0.114 on port 1883.
1563484353: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484353: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484353: Socket error on client ben1, disconnecting.
1563484354: New connection from 10.0.0.114 on port 1883.
1563484354: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484354: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484354: Socket error on client ben1, disconnecting.
1563484354: New connection from 10.0.0.115 on port 1883.
1563484354: New client connected from 10.0.0.115 as mosq/3RUZczbMdfei1nh0rA (p2, c1, k60, u'usr2').
1563484354: Client mosq/3RUZczbMdfei1nh0rA disconnected.
1563484355: New connection from 10.0.0.114 on port 1883.
1563484355: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484355: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484355: Socket error on client ben1, disconnecting.
1563484356: New connection from 10.0.0.114 on port 1883.
1563484356: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484356: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484356: Socket error on client ben1, disconnecting.
1563484357: New connection from 10.0.0.114 on port 1883.
1563484357: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484357: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484357: Socket error on client ben1, disconnecting.
1563484358: New connection from 10.0.0.114 on port 1883.
1563484358: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484358: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484358: Socket error on client ben1, disconnecting.
1563484359: New connection from 10.0.0.114 on port 1883.
1563484359: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484359: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484359: Socket error on client ben1, disconnecting.
1563484360: New connection from 10.0.0.114 on port 1883.
1563484360: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484360: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484360: Socket error on client ben1, disconnecting.
1563484361: New connection from 10.0.0.114 on port 1883.
1563484361: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484361: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484361: Socket error on client ben1, disconnecting.
1563484362: New connection from 10.0.0.114 on port 1883.
1563484362: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484362: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484362: Socket error on client ben1, disconnecting.
1563484363: New connection from 10.0.0.114 on port 1883.
1563484363: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484363: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484363: Socket error on client ben1, disconnecting.
1563484364: New connection from 10.0.0.114 on port 1883.
1563484364: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484364: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484364: Socket error on client ben1, disconnecting.
1563484365: New connection from 10.0.0.114 on port 1883.
1563484365: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484365: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484365: Socket error on client ben1, disconnecting.
1563484366: New connection from 10.0.0.114 on port 1883.
1563484366: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484366: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484366: Socket error on client ben1, disconnecting.
1563484367: New connection from 10.0.0.114 on port 1883.
1563484367: New client connected from 10.0.0.114 as ben1 (p2, c1, k60, u'usr1').
1563484367: Invalid QoS in subscription command from 10.0.0.114, disconnecting.
1563484367: Socket error on client ben1, disconnecting.
@benbarbour

This comment has been minimized.

Copy link
Author

commented Jul 18, 2019

Just poking around near the "Invalid QoS" message and wondering if the protocol version is somehow mismatched between the subscribing client and the broker?

The logs show that I'm subscribing with options "0x20" when the -R flag is passed. It looks like in protocol v5 those options are bit flags that might have something to do with that flag, but the options are assumed to consist only of the QoS in protocol version 3. :/

ralight added a commit that referenced this issue Jul 24, 2019

ralight added a commit that referenced this issue Jul 24, 2019

Fix MQTT v5 sub opts being set for v3 subs.
Closes #1353. Thanks to Ben Barbour.
@ralight

This comment has been minimized.

Copy link
Contributor

commented Jul 24, 2019

You're right, it is setting MQTT v5 subscription options on v3 subscriptions. It should be checking the protocol before setting those options. I've pushed a change that has the library ignore any subscription options if the client isn't using MQTT v5.

@ralight ralight added this to the 1.6.4 milestone Jul 24, 2019

@ralight ralight closed this Aug 1, 2019

vankxr added a commit to vankxr/mosquitto that referenced this issue Aug 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.