Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
paho.mqtt.python
提交
6781c8ed
P
paho.mqtt.python
项目概览
镜像
/
Eclipse Foundation
/
paho.mqtt.python
大约 1 年 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
paho.mqtt.python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6781c8ed
编写于
7月 07, 2021
作者:
R
Roger A. Light
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'sbtinstruments-feat-reconnect-on-protocol-failure' into 1.6.x
上级
116e97ab
1185e1f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
4 deletion
+11
-4
src/paho/mqtt/client.py
src/paho/mqtt/client.py
+11
-4
未找到文件。
src/paho/mqtt/client.py
浏览文件 @
6781c8ed
...
...
@@ -517,7 +517,7 @@ class Client(object):
"""
def
__init__
(
self
,
client_id
=
""
,
clean_session
=
None
,
userdata
=
None
,
protocol
=
MQTTv311
,
transport
=
"tcp"
):
protocol
=
MQTTv311
,
transport
=
"tcp"
,
reconnect_on_failure
=
True
):
"""client_id is the unique client id string used when connecting to the
broker. If client_id is zero length or None, then the behaviour is
defined by which protocol version is in use. If using MQTT v3.1.1, then
...
...
@@ -603,6 +603,7 @@ class Client(object):
self
.
_reconnect_min_delay
=
1
self
.
_reconnect_max_delay
=
120
self
.
_reconnect_delay
=
None
self
.
_reconnect_on_failure
=
reconnect_on_failure
self
.
_ping_t
=
0
self
.
_last_mid
=
0
self
.
_state
=
mqtt_cs_new
...
...
@@ -1740,14 +1741,16 @@ class Client(object):
is useful for the case where you only want to run the MQTT client loop
in your program.
loop_forever() will handle reconnecting for you. If you call
disconnect() in a callback it will return.
loop_forever() will handle reconnecting for you if reconnect_on_failure is
true (this is the default behavior). If you call disconnect() in a callback
it will return.
timeout: The time in seconds to wait for incoming/outgoing network
traffic before timing out and returning.
max_packets: Not currently used.
retry_first_connection: Should the first connection attempt be retried on failure.
This is independent of the reconnect_on_failure setting.
Raises socket.error on first connection failures unless retry_first_connection=True
"""
...
...
@@ -1789,7 +1792,7 @@ class Client(object):
def
should_exit
():
return
self
.
_state
==
mqtt_cs_disconnecting
or
run
is
False
or
self
.
_thread_terminate
is
True
if
should_exit
():
if
should_exit
()
or
not
self
.
_reconnect_on_failure
:
run
=
False
else
:
self
.
_reconnect_wait
()
...
...
@@ -2956,6 +2959,8 @@ class Client(object):
(
flags
,
result
)
=
struct
.
unpack
(
"!BB"
,
self
.
_in_packet
[
'packet'
])
if
self
.
_protocol
==
MQTTv311
:
if
result
==
CONNACK_REFUSED_PROTOCOL_VERSION
:
if
not
self
.
_reconnect_on_failure
:
return
MQTT_ERR_PROTOCOL
self
.
_easy_log
(
MQTT_LOG_DEBUG
,
"Received CONNACK (%s, %s), attempting downgrade to MQTT v3.1."
,
...
...
@@ -2966,6 +2971,8 @@ class Client(object):
return
self
.
reconnect
()
elif
(
result
==
CONNACK_REFUSED_IDENTIFIER_REJECTED
and
self
.
_client_id
==
b
''
):
if
not
self
.
_reconnect_on_failure
:
return
MQTT_ERR_PROTOCOL
self
.
_easy_log
(
MQTT_LOG_DEBUG
,
"Received CONNACK (%s, %s), attempting to use non-empty CID"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录