codmpm / node-red-contrib-loxone

Connect the Loxone Miniserver to node-red via the Websocket API
MIT License
74 stars 24 forks source link

Uncaught Exception - Miniserver Gen2 #37

Closed djatwork closed 4 years ago

djatwork commented 4 years ago

Hi, i tried to connect the loxone to nodered, since i input the credetials the nodered crashes everytime shortly after the start. i´m using a miniserver gen2 with enabled authentication.

29 Dec 11:06:00 - [info] Installing module: node-red-contrib-loxone, version: 0.10.4
29 Dec 11:06:09 - [info] Installed module: node-red-contrib-loxone
29 Dec 11:06:09 - [info] Missing type registered: loxone-miniserver
29 Dec 11:06:09 - [info] Starting flows
29 Dec 11:06:09 - [info] Started flows
29 Dec 11:06:09 - [info] [loxone-miniserver:c00ab406.073b1] Miniserver connected (10.20.1.15:80) using Token-Enc
29 Dec 11:06:09 - [red] Uncaught Exception:
29 Dec 11:06:09 - Error: error:0908F070:PEM routines:get_header_and_data:short header
    at Object.publicEncrypt (internal/crypto/cipher.js:61:12)
    at TokenEnc._generate_session_key (/opt/loxberry/.node-red/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:112:32)
    at IncomingMessage.<anonymous> (/opt/loxberry/.node-red/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:92:18)
    at IncomingMessage.emit (events.js:210:5)
    at IncomingMessage.Readable.read (_stream_readable.js:525:10)
    at flow (_stream_readable.js:1000:34)
    at resume_ (_stream_readable.js:981:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Node-RED version: v1.0.3 Node.js version: v12.14.0 Loxone: 10.3.11.25

when i uninstall the node-red-contrib-loxone, nodered starts again until i install the module again

any hints?

thx Werner

codmpm commented 4 years ago

Hey Werner,

thanks for that much info. Which version of node-red-contrib-loxone are you running? 0.10.4?

As I do not have a miniserver Gen2 nor running LoxBerry, could you check this on a clean node-red install? Maybe use a second SD card for the Pi and install node-red like statet in the tutorial?

To my knowledge the Loxone software for Gen1 and Gen2 are the same. I did not have any issues with 10.3.11.25 on a Gen1 miniserver, yet. Regarding the error messages this seems to be some problem in a nodejs crypto library on which node-lox-ws-api's token_enc relies. Does the Gen2 miniserver serve the websocket over https?

Cheers, Patri

djatwork commented 4 years ago

Hi Patri

yes i´m using the 0.10.4! It´s a clean node-red install on an loxberry VM. I will try to install a new container in the next days.

So the Loxone Config Software is still the same but the gen2 supports https encryption. i think the connection is starting on port 80 and then it will be transfered to the https port 443.

Maybe the problem depends not only to the gen 2 because i saw shortly that the module read out the loxone rooms and configs before it started to crash all the time. so the main communication has to be working for a short period.

is there anything i could debug or test except the clean node red install?

many thx Werner

djatwork commented 4 years ago

Hi,

i duplicated the problem, with a new node-red docker container. On this install it start crashing right after saving the credentials.

Plain node-red install installed 0.10.4 thru the palette draw an loxone online object, add miniserver data (with port 80) draw an control in or control out object to check the if there was data parsed from the miniserver. the node red crashed.

29 Dec 20:21:45 - [info] [loxone-miniserver:5844b2c4.213cec] Miniserver connected (10.20.1.15:80) using Token-Enc                                                                              
29 Dec 20:21:45 - [red] Uncaught Exception:                                                                                                                                                    
29 Dec 20:21:45 - Error: error:0906D066:PEM routines:PEM_read_bio:bad end line                                                                                                                 
    at Object.publicEncrypt (crypto.js:390:12)                                                                                                                                                 
    at TokenEnc._generate_session_key (/data/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:112:32)                                                                                        
    at IncomingMessage.res.on (/data/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:92:18)                                                                                                 
    at emitOne (events.js:116:13)                                                                                                                                                              
    at IncomingMessage.emit (events.js:211:7)                                                                                                                                                  
    at IncomingMessage.Readable.read (_stream_readable.js:475:10)                                                                                                                              
    at flow (_stream_readable.js:846:34)                                                                                                                                                       
    at resume_ (_stream_readable.js:828:3)                                                                                                                                                     
    at _combinedTickCallback (internal/process/next_tick.js:139:11)                                                                                                                            
    at process._tickCallback (internal/process/next_tick.js:181:9)                                                                                                                             
npm ERR! code ELIFECYCLE                                                                                                                                                                       
npm ERR! errno 1                                                                                                                                                                               
npm ERR! node-red-docker@1.0.0 start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS --userDir /data                                                                        
npm ERR! Exit status 1                                                                                                                                                                         
npm ERR!                                                                                                                                                                                       
npm ERR! Failed at the node-red-docker@1.0.0 start script.                                                                                                                                     
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                                                             

npm ERR! A complete log of this run can be found in:                                                                                                                                           
npm ERR!     /usr/src/node-red/.npm/_logs/2019-12-29T20_21_45_180Z-debug.log
codmpm commented 4 years ago

node-lox-ws-api does currently not support connections over https, as this was never an option prior to the Gen2 miniserver.

Could you give me the output of curl -I http://<ip-of-miniserver>/data/LoxAPP3.json?

I think I need a Gen2 miniserver to get hold of this...

elpaso666 commented 4 years ago

I also do not yet have ms gen2, but I am wondering if HTTPS is mandatory settings which eliminates HTTP by design of gen2.

For internal LAN communication with loxone gen2 it should make sense to keep http alive

Jakub

Arrow768 commented 4 years ago

I had the same issue with my miniserver v2 and could resolve it using the fix mentioned here: https://github.com/alladdin/node-lox-ws-api/issues/19

codmpm commented 4 years ago

Thank you! I will incorporate that fix into my fork of node-lox-ws-api till @alladdin does a new release of the lib.

elpaso666 commented 4 years ago

oh, perfect! lets buy v2 then! thx and have a great week ;)

codmpm commented 4 years ago

Should already be fixed on a (re)install of node-red-contrib-loxone as the depending api-repository (codm/node-lox-ws-api) has the fix from @alladdin already pulled.

codmpm commented 4 years ago

@elpaso666, could you please test it?

elpaso666 commented 4 years ago

ah sorry, I cant... my v2 MS went to my brother in law. I will lets right when he replaces the old one with it.