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

subscribe.simple: Fix MQTTv5 clean_session collision #707

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/paho/mqtt/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def simple(topics, qos=0, msg_count=1, retained=True, hostname="localhost",
processed using the tls_set_context method.
Defaults to None, which indicates that TLS should not be used.

protocol : the MQTT protocol version to use. Defaults to MQTTv311.

transport : set to "tcp" to use the default setting of transport which is
raw TCP. Set to "websockets" to use WebSockets as the transport.

Expand All @@ -250,7 +252,8 @@ def simple(topics, qos=0, msg_count=1, retained=True, hostname="localhost",
when it disconnects. If False, the client is a persistent
client and subscription information and queued messages
will be retained when the client disconnects.
Defaults to True.
Defaults to True. If protocoll is MQTTv50, clean_session
is ignored.

proxy_args: a dictionary that will be given to the client.
"""
Expand All @@ -265,6 +268,10 @@ def simple(topics, qos=0, msg_count=1, retained=True, hostname="localhost",
else:
messages = []

# Ignore clean_session if protocol is MQTTv50, otherwise Client will raise
if protocol == paho.MQTTv5:
clean_session = None

userdata = {'retained':retained, 'msg_count':msg_count, 'messages':messages}

callback(_on_message_simple, topics, qos, userdata, hostname, port,
Expand Down