Skip to content

Commit

Permalink
Merge pull request #707 from lnksz/fix_subscribe.simple_mqttv5
Browse files Browse the repository at this point in the history
subscribe.simple: Fix MQTTv5 clean_session collision
  • Loading branch information
PierreF authored Jan 1, 2024
2 parents c3d1865 + 658b952 commit b29e31c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/paho/mqtt/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,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 @@ -249,7 +251,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 @@ -264,6 +267,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

0 comments on commit b29e31c

Please sign in to comment.