0
votes

I'm running a forever script sending data from raspberry pi 3 to azure-iot-hub, using the following, root@raspberrypi3:~# forever start /home/pi/azure/iam/ble_azure.js

After working for about 1.5 days, I stopped getting messages at auzre-iot-hub, when I checked forever list I got the following:

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 

When I checked the log file I get this error message:

/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

Through the log file, mqtt error keeps happening multiple times and forever handled it successfully, what I can't understand why after 1.5 days, I get this error:

**error: Forever detected script exited with code: 7
error: Script restart attempt #34**

Also why I keep getting such mqtt error, why it keeps disconnecting?

**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

Thanks

1

1 Answers

0
votes

If you're using Client.fromConnectionString to instantiate the client object the SDK disconnects and reconnects every 45 minutes to renew the shared access signature token. (it doesn't happen with AMQP that uses a different authentication mechanism). It might be that when re-establishing the connection the client hits this "premature close" error that we've been tracking in this issue.

There are 2 things that could help limit potential errors linked to disconnecting/reconnecting:

Last but not least, the next release of the SDK (1.2.0) will include a retry/reconnect logic that is way more robust than what was there before. I'll update the issue to point to it when it is released.