我正在运行一个永久脚本,使用以下方法将数据从raspberry pi 3发送到azure-iot-hub root @ raspberrypi3:〜#forever start /home/pi/azure/iam/ble_azure.js
工作了大约1.5天后,我停止在auzre-iot-hub收到消息,当我永远检查列表时,我得到了以下内容:
root@raspberrypi3:~# forever list
info: Forever processes running
data: uid command script forever pid id logfile uptime
data: [0] NWgI /usr/bin/nodejs /home/pi/azure/iam/ble_azure.js 8990 3784 /root/.forever/NWgI.log 0:21:17:38.742
当我检查日志文件时,收到以下错误消息:
/home/pi/azure/iam/node_modules/applicationinsights/AutoCollection/Exceptions.js:27
throw error;
^
NotConnectedError: mqtt.js returned client disconnecting error
at translateError (/home/pi/azure/iam/node_modules/azure-iot-device-mqtt/lib/mqtt-translate-error.js:25:11)
at MqttTwinReceiver._handleError (/home/pi/azure/iam/node_modules/azure-iot-device-mqtt/lib/mqtt-twin-receiver.js:201:42)
at /home/pi/azure/iam/node_modules/azure-iot-device-mqtt/lib/mqtt-twin-receiver.js:64:18
at MqttClient._checkDisconnecting (/home/pi/azure/iam/node_modules/mqtt/lib/client.js:314:7)
at MqttClient.subscribe (/home/pi/azure/iam/node_modules/mqtt/lib/client.js:423:12)
at /home/pi/azure/iam/node_modules/azure-iot-device-mqtt/lib/mqtt-twin-receiver.js:62:22
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
error: Forever detected script exited with code: 7
error: Script restart attempt #34
state has changed poweredOn
started scanning
[IoT hub Client] Connect error: mqtt.js returned premature close error
通过日志文件,mqtt错误多次发生并永远成功处理,我无法理解为什么在1.5天后,我收到此错误:
**error: Forever detected script exited with code: 7
error: Script restart attempt #34**
另外,为什么我一直得到这样的mqtt错误,为什么它一直断开连接?
**NotConnectedError: mqtt.js returned client disconnecting error**
Forever --version
v0.15.3
root@raspberrypi3:~# uname -a
Linux raspberrypi3 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
谢谢
答案 0 :(得分:0)
如果您使用Client.fromConnectionString
实例化客户端对象,则SDK会每隔45分钟断开连接并重新连接以续订共享访问签名令牌。 (使用不同的身份验证机制的AMQP不会发生这种情况)。可能是在重新建立连接时,客户端会触及这个过早关闭"我们一直在跟踪in this issue的错误。
有两件事可以帮助限制与断开/重新连接相关的潜在错误:
Client.fromSharedAccessSignature
并构建一个长期签名,不需要经常断开连接和重新连接。 最后但并非最不重要的是,SDK的下一个版本(1.2.0)将包含一个重试/重新连接逻辑,它比之前更强大。我将更新问题,以便在发布时指向它。