Azure-IoT - Raspberry pi3 Forever script exited with code: 7 - node.js

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

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:
Use X509 certificates instead of connection strings to authenticate.
Create a client object using Client.fromSharedAccessSignature and build a long-lived signature that does not require disconnecting and reconnecting as often.
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.

Related

Facing Appium error: Error getting device API level

These are the errors I got, as a test is done on cucumber, appium for mobile testing. I used windows and eclipse (cucumber) and I got these errors, before it was running
Failed to Create Session. The session identified by fca400..... is not known
and when I ran
adb uninstall io.appium.uiautomator2.server; adb uninstall io.appium.uiautomator2.server.test; adb uninstall io.appium.unlock (was throwing error); adb uninstall io.appium.settings
I got the following error
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command 'C:\Users\Diego\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 1115fbab02003004 shell getprop ro.build.version.sdk' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability

NWJS (Node Webkit) app is not responding on Linux systems when I use it with Web Workers

NWJS Version: v.0.32.1 (Tested on different 0.31 versions also and 0.32.beta)
Operating System: Linux only. Tested on Ubuntu 16.04 LTS x64 and Elementary OS 0.4.1 Loki x64
Expected behaviour
The program must respond.
Actual behaviour
The program not responding and if I break it (Ctrl + C) i seen in console that messages:
[14399:14410:0802/142733.750943:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[14399:14410:0802/142733.761023:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[14399:14409:0802/142733.761203:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[14399:14409:0802/142733.761402:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[14399:14409:0802/142733.761801:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[14399:14410:0802/142733.761896:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
But if I'am using nwjs-builder-phoenix and running SDK - working correctly.
How to reproduce
Prepare
Download and extract fake data to parsing: https://github.com/trofivan/myq-jobs-archive-parser/releases/download/v0.1.0/fake-data-big.zip
git clone https://github.com/trofivan/myq-jobs-archive-parser.git
cd myq-jobs-archive-parser
npm i
Working correctly (only with nwjs-builder-phoenix SDK)
npm start
In the opened window click Select folder to parse
Select folder with fake data
Wait some time while data will have parsed.
Use filters
Close the program
Working not correctly
npm run build.dist
cd dist/myq-jobs-archive-parser-0.1.3-linux-x64/
./myq-jobs-archive-parser
Select folder to parse and waiting some time.
The program does not respond.
Close program (Ctrl + C or [x] on the window) and see console output:
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
[16012:16023:0802/145405.677499:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[16012:16023:0802/145405.678176:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[16012:16012:0802/145405.679403:ERROR:broker_posix.cc(104)] Error sending sync broker message: Broken pipe (32)
[16012:16012:0802/145405.679587:ERROR:command_buffer_proxy_impl.cc(100)] ContextResult::kFatalFailure: AllocateAndMapSharedMemory failed
killall exe - to stop the process
PS:
If download nwjs from the official website, working not correctly with SDK version also.
On Linux system program not responded when comes to the game Web Worker: https://github.com/trofivan/myq-jobs-archive-parser/blob/master/src/middlewares/fetchJobs.js
When program not responding I'm can not open Chrome dev tools and get more info.

Parse Server + Express - Issues with ParseError and site dying/restarting

I have deployed a Bitnami Parse stack to a Google Cloud VM. This stack is basically Apache running as a proxy, Then a MEAN stack handling parse server and dashboard etc.
Everything appears to be working fine when accessing the dashboard and sending individual CURL requests to test it's all available.
However, there appears to be a fatal flaw in that. When Parse returns one of it's errors e.g.
{"code":101,"error":"Object not found."}
Express sees it as an uncaught exception and dies. Now I realise that it's intentional behaviour (There's enough information out there as to why you don't want to persist after an uncaught exception)
The Bitnami stack uses Forever to run the Parse Server, but as you can see from the logs I will include below, you still run into issues with refused connections.
2016-11-25T11:41:16+00:00 DEBUG (7): {"code":101,"error":"Object not found."}
2016-11-25T11:41:16+00:00 DEBUG (7): Failed to connect to X.X.X.X: Connection refused
2016-11-25T11:41:17+00:00 DEBUG (7): Failed to connect to X.X.X.X: Connection refused
2016-11-25T11:41:17+00:00 DEBUG (7): Failed to connect to X.X.X.X: Connection refused
2016-11-25T11:41:17+00:00 DEBUG (7): Failed to connect to X.X.X.X: Connection refused
Meanwhile in the Forever logs:
Error generating response. ParseError { code: 101, message: 'Object not found.' } code=101, message=Object not found.
[object Object]
/opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/ParseServer.js:425
throw err;
^
Error: EACCES: permission denied, open '/opt/bitnami/apps/parse/htdocs/logs/parse-server.info.2016-11-25'
at Error (native)
error: Forever detected script exited with code: 7
error: Script restart attempt #1
parse-server running on port 1337
parse-dashboard running on port 4040
So you can see that immediately following a Parse error being returned, The service is unavailable until Forever can restart the Parse Server.
This issue appears that it would affect all users as well, so if one user receives an exception, all users lose connection for a brief period.
So the question is, how should this be properly handled? Is Parse + Express not the way to go about it? Or is there some method of configuring Node or Express to return the API error to the requester, without Express dying (And without having to fall into the trap of using uncaughtException to keep Node alive)
Any help would be much appreciated, thank you
The logs from Forever said it's EACCES error, that means ParseServer couldn't access the log file and not able to write the info log in it.
Error: EACCES: permission denied, open '/opt/bitnami/apps/parse/htdocs/logs/parse-server.info.2016-11-25'
at Error (native)
error: Forever detected script exited with code: 7
error: Script restart attempt #1
parse-server running on port 1337
parse-dashboard running on port 4040
I think you have to change the /opt/bitnami/apps/parse/htdocs/logs with proper permission so that ParseServer can write log files in it.

Error: read ETIMEOUT occurring after some time with node-amqp

I have a VM with a RabbitMQ instance running, and a separate VM with a Node process that will consume things off of a queue.
After some time of inactivity, my Node process will just quit and display an error. I have forever keeping the Node process alive but here is what the error looks like:
data: server.js:18171 - error: Script restart attempt #33
data: server.js:18171 - [rabbitmq] Waiting for messages in savvy_shipping_to_logic. To exit press CTRL+C
data: server.js:18171 - Error: read ETIMEDOUT
data: server.js:18171 - at errnoException (net.js:901:11)
data: server.js:18171 - at TCP.onread (net.js:556:19)
data: server.js:18171 - error: Forever detected script exited with code: 8
data: server.js:18171 - error: Script restart attempt #34
data: server.js:18171 - [rabbitmq] Waiting for messages in savvy_shipping_to_logic. To exit press CTRL+C
data: server.js:18171 - Error: read ETIMEDOUT
data: server.js:18171 - at errnoException (net.js:901:11)
data: server.js:18171 - at TCP.onread (net.js:556:19)
data: server.js:18171 - error: Forever detected script exited with code: 8
data: server.js:18171 - error: Script restart attempt #35
both VMs are Ubuntu 14.04 running on Azure. I should note that I did not experience the same issues locally on my Macbook Pro running El Cap. I feel like I'm missing some flag?
I'm connecting to amqp://my.example.com
you may need to set a heartbeat in your connection setting to keep the connection alive. try adding a heartbeat of 30 seconds, for example, and see if that helps.
you may also want to increase the connection timeout.

heimcontrol.js Node/Mongodb: 'events.js:2817: Uncaught Error: Cannot open /dev/'

I have been struggling for a week trying to figure out what went wrong. I had this running fine from outside my house and controlling an led on a breadboard. When I restarted my pi and attempted to run 'node heimcontrol.js', I am greeted with 'info - socket.io started' (expected), and two instances of 'events.js:2817: Uncaught Error: Cannot open /dev/' and no return of listening on port. I've checked and changed my permissions of /dev/ to 'drwxr-xr-x 12 pi root 3100 Sep 28 15:58 dev'. I know 777 isn't the best practice, but I was trying to see if that was the issue. I've tried to locate the events.js to dig deeper, but no luck. What should I check next? I've run out of ideas.
node v0.10.2
mongo v2.1.1
pi#raspberrypi ~/heimcontrol.js $ node heimcontrol.js
info - socket.io started
events.js:2817: Uncaught Error: Cannot open /dev/
events.js:2817: Uncaught Error: Cannot open /dev/
Thank you very much in advance.
Edit 01: I pointed my Pi browser to 127.0.0.1:8080 and was greeted with a page 'Motion 3.2.12 Running [1] Threads' and a hyperlink 'All' which leads to settings. I am assuming that I created a video module in Heimcontrol and did not finish the setup since Motion detect my camera (RPi camera module). Not familiar with Motion, maybe someone can help guide me.

Resources