codmpm / node-red-contrib-loxone

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

Error when trying to connect to loxone miniserver #58

Closed cocos-cz closed 2 years ago

cocos-cz commented 3 years ago

Hi,

I am trying to get up and running node-red with my loxone miniserver, but the moment I set the miniserver details, nodered starts crashing..

I am getting this error: TypeError: Cannot read property 'closeDescription' of undefined at Connection. (/home/pi/.node-red/node_modules/node-lox-ws-api/lib/Connection.js:64:62) at WebSocketClient.emit (events.js:314:20) at ClientRequest.handleRequestError (/home/pi/.node-red/node_modules/websocket/lib/WebSocketClient.js:227:14) at ClientRequest.emit (events.js:314:20) at Socket.socketErrorListener (_http_client.js:427:9) at Socket.emit (events.js:314:20) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:84:21) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'.

Thats when I try to setup "online" node to test the connection.. When I delete everything from the flow, i am getting: WebSocket error: Socket Error: undefined ERR_STREAM_WRITE_AFTER_END 1006

and after some time crash again... seems like I am not able to connect to the miniserver.. anybody out there, who could help, how to make stable login into miniserver?

R4pi 8GB, on raspberry Pi OS, all updates done.

Thanks

codmpm commented 3 years ago

Hey @cocos-cz,

which miniserver version do you use? Which nodejs version (node -v)? The error you have is emitted from the underlying node-lox-ws-api, not from node-red-contrib-loxone directly.

cocos-cz commented 3 years ago

Hey,

its latest i believe - miniserver version 11.1.9.14.

Node version is v12.20.0

Ok, will try to to check on the node-lox-ws-api as well

codmpm commented 3 years ago

I think you can't do much about node-lox-ws-api, as node-red-contrib-loxone defines the dependencies.

Currently we use our own forked version (https://github.com/codm/node-lox-ws-api) of it. We'll have a look into this...

cocos-cz commented 3 years ago

Some extra info, when I dont have any node in the flow setup, in the log it keeps connecting to miniserver and being bumped the very same second.. at some point I get the error of too many attempts to connect..

on the bottom line, able to connect remotely to miniserver as well as loxberry connecting and working flawless (with same IP, port, user, pass setting...) - thats running on separate raspberry..

michaltaberski commented 3 years ago

I am experiencing the same issue as @cocos-cz. Any update on this one?

Thanks

codmpm commented 3 years ago

Sorry guys. I currently lent my miniserver to a friend as his got broken. He ordered a new one but it's not here, yet. So I can't test this at the moment...

rc-itcon commented 3 years ago

Hi,

I'm facing exactly the same error as mentioned in post-comment https://github.com/codmpm/node-red-contrib-loxone/issues/58#issue-758525037

Thanks

ghost commented 3 years ago

Hello there,

I'm currently facing the same issue as mentioned above. Are there any updates on that issue yet?

Thanks a lot and best regards!

killeriq commented 3 years ago

Hello,

same problem here, after changing password to Loxone in Android App, nodered is not able to connect:

Miniserver connection error: Socket Error: undefined ERR_STREAM_WRITE_AFTER_END (1006)

Even i created new user new pass, same issue, not able to connect :(

killeriq commented 3 years ago

@codmdu any update please?

killeriq commented 3 years ago

@codmdu is this project still alive?

Thanks

codmpm commented 3 years ago

@killeriq What do you mean? This is an open-source project maintained mainly in our free-time.

killeriq commented 3 years ago

well since Dec 7, 2020 no progress at all :(

You mentioned in Feb "Sorry guys. I currently lent my miniserver to a friend as his got broken. He ordered a new one but it's not here, yet. So I can't test this at the moment..."

Problem persist for all guys here seems like...

No clue what happend, was working for me all good, changed only Loxone password, updated also in Nodered and since then is not working...

there was no Loxone version update on my side and plugin in nodered wasnt updated also few months.

As result no data are going to Grafana :(

codmpm commented 3 years ago

Understood. But then please don't use an open-source project which lives from the community and the free work in our spare time if you so heavily depend on it. Maybe contribute instead of nagging people to solve your problem.

Maybe re-read the license:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

https://github.com/codmpm/node-red-contrib-loxone/blob/master/LICENSE

killeriq commented 3 years ago

im not nagging...so don't feel offended ;)

Just asking if there is any progress or someone found some workaround , as there is no update for 5 months.

Maybe there is already some solution , but not mention in here.

If not - would be nice if you find time to have a look what might be the problem. Seems like more issue on Nodered side then on Loxone (if they didnt do any secret update on background)

codmdu commented 3 years ago

@killeriq There is currently no progress, mainly because we are not able to reproduce this issue.

You said it stopped working after you changed the password, could it possible that youre using special chars (could you test it with a simple password?) Which versions are you using right now ? Could you share the logs of your loxone miniserver (after nodered crashed) ?

killeriq commented 3 years ago

testing again...

When i wanted to start up "nodered doscker" i got:

21 Apr 14:14:57 - [info] Starting flows 21 Apr 14:14:57 - [info] Started flows 21 Apr 14:14:57 - [red] Uncaught Exception: 21 Apr 14:14:57 - TypeError: Cannot read property 'closeDescription' of undefined at Connection. (/data/node_modules/node-lox-ws-api/lib/Connection.js:64:62) at WebSocketClient.emit (events.js:198:13) at WebSocketClient.failHandshake (/data/node_modules/websocket/lib/WebSocketClient.js:339:10) at ClientRequest. (/data/node_modules/websocket/lib/WebSocketClient.js:278:18) at ClientRequest.emit (events.js:198:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:111:17) at Socket.socketOnData (_http_client.js:451:20) at Socket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-red-docker@1.3.2 start: node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data" npm ERR! Exit status 1

npm ERR! Failed at the node-red-docker@1.3.2 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! /data/.npm/_logs/2021-04-21T12_14_57_196Z-debug.log


When i stop the docker and start again it works for a while ...but then it end up with same error above

Created new user "nodered" in Loxone WebUI and set nodered as password

and still not able to connect :/

image

image

image

image

killeriq commented 3 years ago

Log from nodereddocker image

killeriq commented 3 years ago

Versions: loxone FW 11.0.5.5 NodeRed 1.3.2 node-red-contrib-loxone 0.5.4 seems there is new update recently so i put 0.6.0

killeriq commented 3 years ago

even after update to node-red-contrib-loxone 0.6.0

it get flooded , to it kills Nodered...and also high load on docker :(

image

codmpm commented 3 years ago

Thanks @killeriq, good info.

Are you sure you talk about node-red-contrib-loxone when refering to 0.6.0? The current version is 0.10.11: https://www.npmjs.com/package/node-red-contrib-loxone

Could you also give us the output of node -v so that we know which nodeJS version you are using?

killeriq commented 3 years ago

ah sry you are right is node-red-contrib-influxdb 0.6.0

correct node-red-contrib-loxone 0.10.11

I backedup all flows and removed all of them...still getting errors in log

killeriq commented 3 years ago

maybe to remove the plugin / Palette might help

But i dont see remove option :( image

rest is Empty...or remove whole Docker and set it up again? image

killeriq commented 3 years ago

Flooding the debug screen like this... image

codmpm commented 3 years ago

You have to delete the nodes in the editor first, thus "in use"....

killeriq commented 3 years ago

I have some progress:

  1. Freshy new install of NodeRed and node-red-contrib-loxone 0.10.11 - Loxone server get connected - woow
  2. Soon as I import the "previous" Flows i get the same problems as before image
  3. So i removed all flows except one and seems like i got connected finally...
  4. Other problem is that even Flows are removed, it have it stored somewhere and is asking for related "Palettes" and therefor it doesnt want to deploy Loxone Flow image image

no clue how to remove them and from where

image

Probably with some upgrade of some nodered or Palette it got messed up ...and this might be issue also for everyone else need to probably manually set everything from scratch as importing put again some wrong values

killeriq commented 3 years ago

again same errors, So i did again Fresh new install, installed only node-red-contrib-loxone 0.10.11 added server image I hit Deploy only with this single Flow / node and again errors image

no damn clue what is causing it :(((

With "GIT" command what is ment to be installed in Nodered UI - Palette? - could this be the problem? As of verison 0.10.4 please make sure, that your system has the git command installed, as the needed library are currently pulled from github. Otherwise you will get an undefined ls-remote-Error.

codmpm commented 3 years ago

If you were missing git you can't install node-red-contrib-loxone as a dependency is installed via git.

@codmdu will have a look tomorrow.

killeriq commented 3 years ago
  1. i was able to install "node-red-contrib-loxone 0.10.11" , but just to be sure how do I check if is installed?

  2. Or you meant without GIT part already installed i wouldnt be able to install "node-red-contrib-loxone 0.10.11? ?

killeriq commented 3 years ago

@codmpm any results? Thanks

macabros999 commented 3 years ago

Found a workaround, if you have an user which is created in loxone config version I think before 10 and "important" you didn't change the password in the new version, you can get the script back working.

you can identify old accounts with old password in loxone config, as it's not showing the passwort strength indicator:

Account with old Password image

new Passwords are visible with the password strength indicator: image

I think, like @codmpm, that it isn't a problem with node-red-contrib-loxone script, the problem seems to be the node-lox-ws-api, maybe it doesn't get the right token back from miniserver. As I try to authenticate with an new created password or account, the loxone monitor writes 401 Unauthorized.

so if you have an account with an old password before Lox Config 10, you can get the function back.

killeriq commented 3 years ago

Thanks for the tip, but unfortunately i dont have any "old acccounts" :(

codmdu commented 3 years ago

@macabros999 Thank you for sharing the information with us. Sadly i can't reproduce the issue. I created a new user (which shows the password strength indicator) on the loxone miniserver, but i'm still able to connect to the server through the loxone node.

killeriq commented 3 years ago

@codmdu on which version of Loxone Config / Miniserver FW are you?

codmdu commented 3 years ago

Miniserver: 12.0.2.24 Loxone Config: 12.02.24

killeriq commented 3 years ago

ok, i'm doing backup and will do upgrade from 11.0.5.5 to 12.02.24 to see if it helps. Drives me nuts that "professional" loxone updates, never knows what stop to work

killeriq commented 3 years ago

Seems like they messed up something in Loxone, after they introduced additional Groups / Rights

Here are my test results (I can creating users in LoxConfig 12.0.2.24) , In the end i think upgrade wasn't necessary to do Soon as i added multiple accounts with different right and one of them wasnt working it messed up all (even working) accounts and Nodered was throwing errors. When i removed NON working account, all was good again.

  1. former Admin account is only part of "Admin groups" but has no rights in here Nodered - not working image
  2. Created new user "test" and is part of "Admin groups" with rights in here Nodered - working image
  3. Created new user "nod" and is NOT part of "Admin groups" with NO rights in here Nodered - not working image
  4. Created new user "test1" and is part of "Admin groups" with NO rights in here Nodered - working image
  5. Created new user "test1" and is NOT part of "Admin groups" with rights in here Nodered - working image
killeriq commented 3 years ago

Now even im able to connect - only what get sent "time to time" in "stream all" node is this. everything else is not sending anything :( Strange...any clue what might be issue now? image

killeriq commented 3 years ago

Even after few days, no data are going through. I was comparing how is the membership and rights - Soon as i Add user into "Everyone" user group...it start to throw errors again image Also not able to connect :(

image

Which groups / rights are you using please? Seems like Loxone did huge mess again :(

killeriq commented 3 years ago

Finally was able to get it working, really pain in the ...

Working: Tester1 - "Full Access" - - Connected get structure , getting all data

NOT Working Tester - "Admins" - Connected get structure , but NOT getting any data

admin - "Admins","Full Acccess" - NOT Connected, NO structure , NOT getting any data

nodered - "User" - Connected get structure , but NOT getting any data

v-sante commented 3 years ago

Finally was able to get it working, really pain in the ...

Working: Tester1 - "Full Access" - - Connected get structure , getting all data

NOT Working Tester - "Admins" - Connected get structure , but NOT getting any data

admin - "Admins","Full Acccess" - NOT Connected, NO structure , NOT getting any data

nodered - "User" - Connected get structure , but NOT getting any data

  • Also tried to give all rights and still - Connected get structure , but NOT getting any data
  • Seems like all Rooms / Block which need to be monitored needs to be added manually then it might work for the specific room / Block

Having exactly the same problem.

Do you think you can set out exactly how to implement a working configuration in Loxone?

VelkyVenik commented 2 years ago

I have the same issue. I did some debugging and looks like a problem in encrypted communication, so in node-lox-ws-ap. I was able to reproduce the problem with a simple script:

const node_lox_ws_api = require("node_lox_ws_api");

let client = new node_lox_ws_api( '192.168.88.30:80', 'nodered', 'password', false, 'Token-Enc', true );

client.connect()

Miniserver started to drop all connections after a couple of tries.

I tried steps that @killeriq described without any success. From the code, it looks like the first error message is sent during keys exchange, so even before the user name is sent to miniserver. It is weird :)

codmpm commented 2 years ago

Hey @VelkyVenik, thanks for the debugging. Maybe @alladdin can have a look at this?

bausi2k commented 2 years ago

same for me - but just since the last Config changes - no user/permissions - from today. It was working pretty good.

killeriq commented 2 years ago

guys try to use the rules i posted before, spend few days with that until i figure it out....you need to give to new account additional rights

martindudek commented 2 years ago

what additional rights you have? I gave it rights to literally everything and not working. I run Lox. 12.2.12.1. I see the structure, but after deploy it crashes

aveslawa commented 2 years ago

I have the same situation as @martindudek I use: Loxone ver. 12.2.12.01, node-red-contrib-loxone ver. 0.10.11, also, I created a separate user with full rights permission and the most complex password. Need your help

codmpm commented 2 years ago

Please test this issue with 0.10.12 which was released right now.

Thanks to @arsiesis, @pevecyan and @umarovt for having a look into node-lox-ws-api which should relate to this.

codmpm commented 2 years ago

Leaving open till marked as solved :+1:

croghostrider commented 2 years ago

hi @codmpm

for me, the fix solves the problem. I have tested this on a new-gen. Miniserver Go with version 12.2.12.1.