AshMartian / node-red-unofficial-sense

Unofficial Sense API implementation for Node-Red
2 stars 1 forks source link

sense config causes node-red to crash #1

Open brentratliff opened 3 years ago

brentratliff commented 3 years ago

When using sense-now I get a syntax error and the GUI disconnects from the server. Disabling node-red-unofficial-sense in the json config reconnects the server.

brentratliff commented 3 years ago

Error: write EPROTO 1995863712:error:1414D172:SSL routines:tls12_check_peer_sigalg:wrong signature type:../deps/openssl/openssl/ssl/t1_lib.c:1146: at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'.

brentratliff commented 3 years ago

I know this code is three years old. I'm guessing something to do with authentication. Let me know if you're no longer working on this project.

brentratliff commented 3 years ago

It's definitely the configuration node. When I delete and deploy the config node, node-red does not disconnect. I'm guessing sense has changed their authentication since 2018.

AshMartian commented 3 years ago

It’s definitely changed slightly, my node-red has been throwing some auth errors, but haven’t had the time to dig into it. I haven’t had any usability problems, sense node-red still making my Google home notify me when microwave goes off. Used to have issues when using the app, but just checked the app today and both responding.

brentratliff commented 3 years ago

Can you point me in the direction of the authentication piece? I couldn't find the API call in the code?

brentratliff commented 3 years ago

I wonder if yours still works since you already have an Auth token. It’s an SSL error so may be a quick fix.

brentratliff commented 3 years ago

This seems to be affecting other users of the API, not just those using node or node red. The issue appears related to outdated SSL settings on the Sense servers. I was able to get this running on a Mac unlike the Pi.

This issue is actually caused by the security levels set by the web site, in this case Sense. The default security level in Debian 10/OpenSSL 1.1.1b conflict with the lower security of whatever web application. You can read more about this here: https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1 77

Basically, you need to lower the default level back down to level 1. This really is a workaround, the sites in question should be updating their security. To do this you need to open up /etc/ssl/openssl.cnf and change “CipherString” from “DEFAULT@SECLEVEL=2” to “DEFAULT@SECLEVEL=1” Then you will have to reboot your system.

My Mac is not always running, but now I know the problem, I can either get it working on the Pi or possibly my always on Win10 server.

brentratliff commented 3 years ago

[red] Uncaught Exception: 18 Mar 12:40:50 - FetchError: invalid json response body at https://api.sense.com/apiservice/api/v1/app/monitors/xxxxxx/devices reason: Unexpected token < in JSON at position 0

Getting this on Windows using Node 15. Not getting it on the LTS versions on Mac or Rasbpian. Is there a way I can add error checking into the api call?

rossphillips70 commented 3 years ago

Is there a fix for this yet? I believe this is causing my Node-Red to crash.

0|node-red | FetchError: invalid json response body at https://api.sense.com/apiservice/api/v1/app/monitors/xxxxxx/devices reason: Unexpected token < in JSON at position 0 0|node-red | at /home/node-red/node_modules/node-fetch/lib/index.js:272:32 0|node-red | at runMicrotasks () 0|node-red | at processTicksAndRejections (internal/process/task_queues.js:97:5) 0|node-red | at async /home/node-red/node_modules/unofficial-sense/index.js:70:42 { 0|node-red | message: 'invalid json response body at https://api.sense.com/apiservice/api/v1/app/monitors/xxxxxx/devices reason: Unexpected token < in JSON at position 0', 0|node-red | type: 'invalid-json' 0|node-red | }

andrewvanlagen commented 1 year ago

anyone have a fix for this issue