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

Request for persistent sessions ignored. #1272

Closed
BowenMarmot opened this issue May 9, 2019 · 9 comments

Comments

@BowenMarmot
Copy link

commented May 9, 2019

I upgraded to 1.6.2 on my raspberry pi. It seems that all session retention is being ignored by the broker.

I connect to the broker with qos and disable-clean-session set.

scott@elizabeth:~ $ mosquitto_sub -d -v -h 127.0.0.1 -p 1883 -t 'owntracks/#' --id scottroot --qos 2 --disable-clean-session
Client scottroot sending CONNECT
Client scottroot received CONNACK (0)
Client scottroot sending SUBSCRIBE (Mid: 1, Topic: owntracks/#, QoS: 2, Options: 0x00)
Client scottroot received SUBACK
Subscribed (mid: 1): 2

The log file shows that the CONNACK is returned with the "Session Present Flag" set to 0 which means the server did not set a persistent session.

1557432182: New connection from 127.0.0.1 on port 1883.
1557432182: New client connected from 127.0.0.1 as scottroot (p2, c0, k60).
1557432182: No will message specified.
1557432182: Sending CONNACK to scottroot (0, 0)
1557432182: Received SUBSCRIBE from scottroot
1557432182:     owntracks/# (QoS 2)
1557432182: scottroot 2 owntracks/#
1557432182: Sending SUBACK to scottroot

This is supported in the tcpdump. The first bold 00 shows a "clean session" is not requested. The second bold 00 is saying that a persistent session is not supplied. The bolding is hard to see but it is there. I wish github did colours.


scott@elizabeth:/var/lib/mosquitto $ sudo tcpdump -i lo port 1883 -s0 -X
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes


13:03:02.497769 IP localhost.44412 > localhost.1883: Flags [S], seq 358873496, win 43690, options [mss 65495,sackOK,TS val 251249010 ecr 0,nop,wscale 7], length 0
        0x0000:  4500 003c eaec 4000 4006 51cd 7f00 0001  E..<..@.@.Q.....
        0x0010:  7f00 0001 ad7c 075b 1563 f998 0000 0000  .....|.[.c......
        0x0020:  a002 aaaa fe30 0000 0204 ffd7 0402 080a  .....0..........
        0x0030:  0ef9 c172 0000 0000 0103 0307            ...r........
13:03:02.497829 IP localhost.1883 > localhost.44412: Flags [S.], seq 2159271016, ack 358873497, win 43690, options [mss 65495,sackOK,TS val 251249011 ecr 251249010,nop,ws
cale 7], length 0
        0x0000:  4500 003c 0000 4000 4006 3cba 7f00 0001  E..<..@.@.<.....
        0x0010:  7f00 0001 075b ad7c 80b3 dc68 1563 f999  .....[.|...h.c..
        0x0020:  a012 aaaa fe30 0000 0204 ffd7 0402 080a  .....0..........
        0x0030:  0ef9 c173 0ef9 c172 0103 0307            ...s...r....
13:03:02.497883 IP localhost.44412 > localhost.1883: Flags [.], ack 1, win 342, options [nop,nop,TS val 251249011 ecr 251249011], length 0
        0x0000:  4500 0034 eaed 4000 4006 51d4 7f00 0001  E..4..@.@.Q.....
        0x0010:  7f00 0001 ad7c 075b 1563 f999 80b3 dc69  .....|.[.c.....i
        0x0020:  8010 0156 fe28 0000 0101 080a 0ef9 c173  ...V.(.........s
        0x0030:  0ef9 c173                                ...s
13:03:02.498642 IP localhost.44412 > localhost.1883: Flags [P.], seq 1:24, ack 1, win 342, options [nop,nop,TS val 251249011 ecr 251249011], length 23
        0x0000:  4500 004b eaee 4000 4006 51bc 7f00 0001  E..K..@.@.Q.....
        0x0010:  7f00 0001 ad7c 075b 1563 f999 80b3 dc69  .....|.[.c.....i
        0x0020:  8018 0156 fe3f 0000 0101 080a 0ef9 c173  ...V.?.........s
        0x0030:  0ef9 c173 1015 0004 4d51 5454 0400 003c  ...s....MQTT...<
        0x0040:  0009 7363 6f74 7472 6f6f 74              ..scottroot
13:03:02.498682 IP localhost.1883 > localhost.44412: Flags [.], ack 24, win 342, options [nop,nop,TS val 251249011 ecr 251249011], length 0
        0x0000:  4500 0034 cf1d 4000 4006 6da4 7f00 0001  E..4..@.@.m.....
        0x0010:  7f00 0001 075b ad7c 80b3 dc69 1563 f9b0  .....[.|...i.c..
        0x0020:  8010 0156 fe28 0000 0101 080a 0ef9 c173  ...V.(.........s
        0x0030:  0ef9 c173                                ...s
13:03:02.498814 IP localhost.1883 > localhost.44412: Flags [P.], seq 1:5, ack 24, win 342, options [nop,nop,TS val 251249012 ecr 251249011], length 4
        0x0000:  4500 0038 cf1e 4000 4006 6d9f 7f00 0001  E..8..@.@.m.....
        0x0010:  7f00 0001 075b ad7c 80b3 dc69 1563 f9b0  .....[.|...i.c..
        0x0020:  8018 0156 fe2c 0000 0101 080a 0ef9 c174  ...V.,.........t
        0x0030:  0ef9 c173 2002 0000                      ...s....
13:03:02.498845 IP localhost.44412 > localhost.1883: Flags [.], ack 5, win 342, options [nop,nop,TS val 251249012 ecr 251249012], length 0
        0x0000:  4500 0034 eaef 4000 4006 51d2 7f00 0001  E..4..@.@.Q.....
        0x0010:  7f00 0001 ad7c 075b 1563 f9b0 80b3 dc6d  .....|.[.c.....m
        0x0020:  8010 0156 fe28 0000 0101 080a 0ef9 c174  ...V.(.........t
        0x0030:  0ef9 c174                                ...t
@ralight

This comment has been minimized.

Copy link
Contributor

commented May 10, 2019

The session present flag will never be set the first time you connect. It is used to indicate to the client that there is a saved session on the broker or not. So try the steps below and you should see the flag set to 1 the second time.

mosquitto_sub -d -v -h 127.0.0.1 -p 1883 -t 'owntracks/#' --id scottroot --qos 2 --disable-clean-session
<ctrl-c>
mosquitto_sub -d -v -h 127.0.0.1 -p 1883 -t 'owntracks/#' --id scottroot --qos 2 --disable-clean-session
@BowenMarmot

This comment has been minimized.

Copy link
Author

commented May 10, 2019

Thanks much for the reply. Unfortunately, I can only wish that were the problem. I had to give it another try though as I have spent a bunch of hours trying to understand where the problem lies that who knows, I could have missed this case. The results are below.

Client with debug

scott@elizabeth:~ $ mosquitto_sub -d -v -h 127.0.0.1 -p 1883 -t 'owntracks/#' --id scottroot --qos 2 --disable-clean-session 
Client scottroot sending CONNECT
Client scottroot received CONNACK (0)
Client scottroot sending SUBSCRIBE (Mid: 1, Topic: owntracks/#, QoS: 2, Options: 0x00)
Client scottroot received SUBACK
Subscribed (mid: 1): 2
^C
scott@elizabeth:~ $ mosquitto_sub -d -v -h 127.0.0.1 -p 1883 -t 'owntracks/#' --id scottroot --qos 2 --disable-clean-session 
Client scottroot sending CONNECT
Client scottroot received CONNACK (0)
Client scottroot sending SUBSCRIBE (Mid: 1, Topic: owntracks/#, QoS: 2, Options: 0x00)
Client scottroot received SUBACK
Subscribed (mid: 1): 2
^C
scott@elizabeth:~ $ 

mosquitto.log

1557492236: New connection from 127.0.0.1 on port 1883.
1557492236: New client connected from 127.0.0.1 as scottroot (p2, c0, k60).
1557492236: No will message specified.
1557492236: Sending CONNACK to scottroot (0, 0)
1557492236: Received SUBSCRIBE from scottroot
1557492236:     owntracks/# (QoS 2)
1557492236: scottroot 2 owntracks/#
1557492236: Sending SUBACK to scottroot
1557492238: Socket error on client scottroot, disconnecting.
1557492244: New connection from 127.0.0.1 on port 1883.
1557492244: New client connected from 127.0.0.1 as scottroot (p2, c0, k60).
1557492244: No will message specified.
1557492244: Sending CONNACK to scottroot (0, 0)
1557492244: Received SUBSCRIBE from scottroot
1557492244:     owntracks/# (QoS 2)
1557492244: scottroot 2 owntracks/#
1557492244: Sending SUBACK to scottroot
1557492249: Socket error on client scottroot, disconnecting.
``
@ralight

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

I'm fairly certain that this has been fixed with the same commit as #1273. If you feel like testing it, you could get the fixes branch to see whether it works for you. If you aren't sure how to do that I can help.

@addendumE

This comment has been minimized.

Copy link

commented Jun 18, 2019

@ralight I'm facing the same issue too with version 1.6.2. Clean session set to false is ignored by the broker. I'm available for testing but I need you help

@ralight

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2019

@addendumE I'm just preparing the 1.6.3 release, so it might be best to test that instead.

@addendumE

This comment has been minimized.

Copy link

commented Jun 19, 2019

@ralight

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2019

I've tested this and am confident the fix I've pushed to the fixes branch solves this problem.

@BowenMarmot

This comment has been minimized.

Copy link
Author

commented Jun 25, 2019

Well, dang. The 1.6.3 release just became available in the repo (repo.mosquitto.com) and I was just able to install it and test it and find that it is still not working. I come here to report it to find that it has already been found and fixed. YAY!

Since I am running on a PI and don't have a development environment to compile for the PI, it seems I will have to wait for the next release. Unless, of course, there is a source for the RasPi binary of which I am not aware.

@addendumE

This comment has been minimized.

Copy link

commented Jun 26, 2019

@ralight ralight closed this in d17d7c9 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
3 participants
You can’t perform that action at this time.