From bb0dbc1c2ffd0616500d3ec27dbd09884866d8a6 Mon Sep 17 00:00:00 2001 From: Darkgod <1107763961@qq.com> Date: Thu, 1 Jul 2021 15:00:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BD=BF=E7=94=A8IsConnectionOpen=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2IsConnected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这里判断是否连接成功使用IsConnectionOpen()方法更准确,因为在断线重连状态IsConnected()也会返回true,但是当断线状态调用BatchReportSubDevicesProperties()会造成阻塞,且无法恢复 --- base_device.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_device.go b/base_device.go index 4334b63..57e42a8 100644 --- a/base_device.go +++ b/base_device.go @@ -149,7 +149,7 @@ func (device *baseIotDevice) DisConnect() { } func (device *baseIotDevice) IsConnected() bool { if device.Client != nil { - return device.Client.IsConnected() + return device.Client.IsConnectedOpen() } return false From f5dbef243b286a31e6d771d4c6397fdf8bf6010e Mon Sep 17 00:00:00 2001 From: Darkgod <1107763961@qq.com> Date: Thu, 1 Jul 2021 15:02:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=86=99=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base_device.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_device.go b/base_device.go index 57e42a8..bbc66fc 100644 --- a/base_device.go +++ b/base_device.go @@ -149,7 +149,7 @@ func (device *baseIotDevice) DisConnect() { } func (device *baseIotDevice) IsConnected() bool { if device.Client != nil { - return device.Client.IsConnectedOpen() + return device.Client.IsConnectionOpen() } return false From 9cde017b6985614764774522e83401ec10971d7b Mon Sep 17 00:00:00 2001 From: Darkgod <1107763961@qq.com> Date: Thu, 1 Jul 2021 15:04:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E9=97=B4=E9=9A=94=E4=B8=BA10s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置重连间隔时间10s,否则重连时间过长,导致消息丢失 --- base_device.go | 1 + 1 file changed, 1 insertion(+) diff --git a/base_device.go b/base_device.go index bbc66fc..aa4ccdd 100644 --- a/base_device.go +++ b/base_device.go @@ -165,6 +165,7 @@ func (device *baseIotDevice) Init() bool { options.SetKeepAlive(250 * time.Second) options.SetAutoReconnect(true) options.SetConnectRetry(true) + options.SetConnectRetryInterval(10 * time.Second) options.SetConnectTimeout(2 * time.Second) if strings.Contains(device.Servers, "tls") || strings.Contains(device.Servers, "ssl") { glog.Infof("server support tls connection") From df70de0cae706f29b9231607dfd7c481c901736d Mon Sep 17 00:00:00 2001 From: Darkgod <1107763961@qq.com> Date: Thu, 1 Jul 2021 15:15:58 +0800 Subject: [PATCH 4/5] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3a3a952..6ac193f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ctlove0523/huaweicloud-iot-device-sdk-go +module github.com/DarkGodOne/huaweicloud-iot-device-sdk-go go 1.15 From 8451ba602b751c1d153af5ac4513be39c14899b1 Mon Sep 17 00:00:00 2001 From: Darkgod <1107763961@qq.com> Date: Thu, 1 Jul 2021 15:34:19 +0800 Subject: [PATCH 5/5] Update sdk_info --- sdk_info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk_info b/sdk_info index 44f418d..f4c9ae0 100644 --- a/sdk_info +++ b/sdk_info @@ -1,2 +1,2 @@ -author = chen tong -sdk-version = v1.0.0 +author = chen tong,changed by darkgod +sdk-version = v1.0.0-patch