RayPS / node-red-contrib-pushover

A Node-RED node to send Pushover notification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-red crash if no internet connection

dezral opened this issue · comments

I have seen this crash a few times now.. it seems it is contrib-pushover that crashes when there is an illegal json of sort.. what the content is i have not managed to catch.

5 Feb 17:29:08 - [red] Uncaught Exception:
5 Feb 17:29:08 - SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at Request._callback (/home/user/.node-red/node_modules/node-red-contrib-pushover/pushover.js:180:39)
at self.callback (/home/user/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:185:22)
at Request.emit (events.js:187:15)
at Request.onRequestError (/home/user/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:182:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

I think i know why, it happens if i send to many messages at a time.. i have if my network reboot or server og anything a like.. i get a message on pushover with priority -2 and that can be up to 30 messages from devices to the node within a few seconds.

The problem is when there is no internet Line or it cant reach Pushover then the plugin crashes node-red..

Can that be fixet?

commented

You have to use pushover with a stable internet connections.

I have fiber. But it should not crash all off node-red

it keeps happening, and it is the only thing that crashes my node-red.. i have put in an online checker(if it sees google.com) and rate-limit but still happens..

im on an fiber internet line, i have an UPS on both my server and router/ap.. so it decently not that i don't have an stable internet connection...

i would love to help you fix this.. im no node/js programmer..but i do know a little programing as i am a sysadmin/tester for more then one company..

this is the latest error caught!.
17 Apr 10:05:09 - [red] Uncaught Exception:
17 Apr 10:05:09 - SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at Request._callback (/home/test/.node-red/node_modules/node-red-contrib-pushover/pushover.js:110:39)
at self.callback (/home/test/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:185:22)
at Request.emit (events.js:194:15)
at Request.onRequestError (/home/test/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:189:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

commented

I believe this issue is fixable, can you provide a payload that lets me reproduce this error.

have setup a delay so i should catch the payload before it crashes node-red and write it to a file..

commented

It's been a while, did you catch that reproducible payload?

it seems like it the Glances API that could make the problem.. at least i have not been able for force an error with normal pushover messages.

will set up a test that sends via Glances API.. and see

latest from when i upgraded my router.., but can't get it to save the payload when it happens..

19 May 10:30:54 - [info] [glances:e76daeaa.3d28b8] pushover POST succeeded:
"{"status":1,"request":"1c53a009-6462-4b5b-b214-27e3c7d4c841"}"
19 May 10:36:18 - [info] [glances:e76daeaa.3d28b8] pushover POST succeeded:
"{"status":1,"request":"c0dbed77-0b48-4a11-ae75-d955ba626c79"}"
19 May 10:47:07 - [info] [glances:e76daeaa.3d28b8] pushover POST succeeded:
"{"status":1,"request":"44331f8a-e653-480a-ae6a-f73ac00ad298"}"
19 May 11:21:32 - [info] [glances:e76daeaa.3d28b8] pushover POST succeeded:
"{"status":1,"request":"f906d45b-b85b-4a8e-8f5c-3b507072db7d"}"
19 May 12:03:18 - [info] [glances:e76daeaa.3d28b8] pushover POST succeeded:
"{"status":1,"request":"145554bc-6004-4969-b76f-cf9ceda90905"}"
19 May 13:16:56 - [red] Uncaught Exception:
19 May 13:16:56 - SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at Request._callback (/home/nodeme/.node-red/node_modules/node-red-contrib-pushover/pushover.js:110:39)
at self.callback (/home/nodeme/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:185:22)
at Request.emit (events.js:194:15)
at Request.onRequestError (/home/nodeme/.node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:189:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

Same here, the JSON.parse needs to go into into a try block. Now that node-red-nodes-pushover supports images I'll probably switch back, else the fix is pretty easy. The problem happens when the internet connection goes down:

29 May 16:52:06 - [red] Uncaught Exception:
29 May 16:52:06 - SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/usr/src/node-red/node_modules/node-red-contrib-pushover/pushover.js:110:39)
    at self.callback (/usr/src/node-red/node_modules/node-red-contrib-pushover/node_modules/request/request.js:185:22)
commented

Should fixed with 2e94ce5 for 0.1.9

nice, will update when it is released.