提交 849f7433 编写于 作者: H Hmvp

Remove message from inflight when not connected

Publishes with qos > 0 which are sent before a CONACK is received are still counted as inflight
even though they don't really get sent.  This means they get sent after the retry period (20 sec default)

But this won't work when max_inflight is 1 since this means no retry will get sent and we wait untill keepalive is exhausted
This then forces a reconnect and will reset stuff so messages can be sent.

Change-Id: I516a6cce8e5bbfbd3030711a80044af4e5bf6733
Signed-off-by: NHmvp <hmvp@hmvp.nl>
上级 3273793f
......@@ -909,6 +909,16 @@ class Client(object):
self._out_message_mutex.release()
rc = self._send_publish(message.mid, message.topic, message.payload, message.qos, message.retain, message.dup)
# remove from inflight messages so it will be send after a connection is made
if rc is MQTT_ERR_NO_CONN:
with self._out_message_mutex:
self._inflight_messages -= 1
if qos == 1:
message.state = mqtt_ms_publish_qos1
elif qos == 2:
message.state = mqtt_ms_publish_qos2
return (rc, local_mid)
else:
message.state = mqtt_ms_queued;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册