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

session is false why can not receive offline messages #1081

Closed
dwin-wangjt opened this issue Dec 14, 2018 · 5 comments
Closed

session is false why can not receive offline messages #1081

dwin-wangjt opened this issue Dec 14, 2018 · 5 comments

Comments

@dwin-wangjt
Copy link

No description provided.

@ralight ralight added the Type: Question A query or clarification. label Dec 18, 2018
@ralight
Copy link
Contributor

ralight commented Dec 18, 2018

There are a few possibilities:

  • You haven't used the same client id for all connections
  • You haven't subscribed with QoS > 0
  • No messages were published on the topics you subscribe to, and had QoS > 0
  • You have the broker configured with persistence false (the default) and you restarted the broker

@alflexRH
Copy link

alflexRH commented Jan 25, 2019

I am in the process of debugging a similar issue.
my publish command: mosquitto_pub -t 'test' -m 'test' -q 2
my subscribe command: mosquitto_sub -t 'test' -q 2 -c -i testing

my sequence:

  1. start subscriber
  2. publish
    -- message arrives
  3. kill subscriber
  4. publish again
  5. start subscriber again
    -- i now expect a message, but there is nothing.

server is configured with 'persistence true'

sub,pub and server version is 1.5.5 on Debian.

@karlp
Copy link
Contributor

karlp commented Jan 25, 2019

works here.

karlp@strem:~$ mosquitto_sub -t 'test' -q 2 -c -i testing
^Z
[1]+  Stopped                 mosquitto_sub -t 'test' -q 2 -c -i testing
karlp@strem:~$ bg
[1]+ mosquitto_sub -t 'test' -q 2 -c -i testing &
karlp@strem:~$ 
karlp@strem:~$ 
karlp@strem:~$ mosquitto_pub -t 'test' -m 'test' -q 2
test
karlp@strem:~$ mosquitto_pub -t 'test' -m 'test' -q 2
test
karlp@strem:~$ fg
mosquitto_sub -t 'test' -q 2 -c -i testing
^C
(subscriber now offline)
karlp@strem:~$ mosquitto_pub -t 'test' -m 'test2' -q 2
karlp@strem:~$ mosquitto_pub -t 'test' -m 'test3' -q 2
karlp@strem:~$ mosquitto_pub -t 'test' -m 'test4' -q 2
( publish three more messages)
karlp@strem:~$ mosquitto_sub -t 'test' -q 2 -c -i testing &
[1] 26426
test2
test3
test4
karlp@strem:~$
( all messages received)

This is independent of persistence, that just determines whether stored messages persist across broker restarts

@alflexRH
Copy link

Thanks for testing. it convinced me it was a config-related error so i kept trying, and i found something: it happens when i set per_listener_settings to true.
this is my config:

per_listener_settings true
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
listener 1883 127.0.0.1
protocol mqtt
max_connections 10
allow_anonymous true

If i set the per_listener_settings to false, it works as expected. may be there is another settings, apart from the listed ones: password_file, acl_file, psk_file, allow_anonymous, allow_zero_length_clientid, auth_plugin, auth_opt_*, auto_id_prefix, that is at play here?

@ralight
Copy link
Contributor

ralight commented Feb 5, 2019

Thanks for the follow up details, I can confirm that this was a bug and I've fixed it in my local branch will be part of 1.5.6 soon.

@ralight ralight added Type: Bug Component: mosquitto-broker and removed Type: Question A query or clarification. labels Feb 5, 2019
@ralight ralight closed this as completed in f952ae3 Feb 8, 2019
ralight added a commit that referenced this issue Apr 25, 2019
This occurred when per_listener_settings was set to true.

Closes #1081. Thanks to dwin-wangjt.
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants