Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes node-red #8

Closed
Drachenkaetzchen opened this issue Sep 21, 2022 · 13 comments
Closed

Crashes node-red #8

Drachenkaetzchen opened this issue Sep 21, 2022 · 13 comments

Comments

@Drachenkaetzchen
Copy link

Node Red Version 3.02 (Docker Image)
moonNode from today, fresh install

Added a moonNode Monitor node. Created a new connection, filled in voron-klipper.feli-home.drachenkatze.org:7125 for the WS and http://voron-klipper.feli-home.drachenkatze.org:7125 for the API fields. Clicked "Done", then "Refresh". Node Red crashes.

Backtrace:

[error] TypeError: Cannot read properties of null (reading 'credentials')\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536223231Z"}
{"log":"    at /data/node_modules/node-red-contrib-moonnode/MoonNode.js:24:22\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536318488Z"}
{"log":"    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536344191Z"}
{"log":"    at next (/usr/src/node-red/node_modules/express/lib/router/route.js:144:13)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536363858Z"}
{"log":"    at /usr/src/node-red/node_modules/@node-red/editor-api/lib/auth/index.js:69:28\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536381857Z"}
{"log":"    at complete (/usr/src/node-red/node_modules/passport/lib/middleware/authenticate.js:271:13)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536398802Z"}
{"log":"    at /usr/src/node-red/node_modules/passport/lib/middleware/authenticate.js:278:15\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536415635Z"}
{"log":"    at pass (/usr/src/node-red/node_modules/passport/lib/authenticator.js:428:14)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.53643256Z"}
{"log":"    at Authenticator.transformAuthInfo (/usr/src/node-red/node_modules/passport/lib/authenticator.js:450:5)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536450041Z"}
{"log":"    at /usr/src/node-red/node_modules/passport/lib/middleware/authenticate.js:275:22\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536467245Z"}
{"log":"    at IncomingMessage.req.login.req.logIn (/usr/src/node-red/node_modules/passport/lib/http/request.js:44:13)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.536882219Z"}
{"log":"    at Strategy.strategy.success (/usr/src/node-red/node_modules/passport/lib/middleware/authenticate.js:256:13)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.537274916Z"}
{"log":"    at verified (/usr/src/node-red/node_modules/passport-http-bearer/lib/strategy.js:126:10)\r\n","stream":"stdout","time":"2022-09-21T18:40:05.53732747Z"}
{"log":"    at /usr/src/node-red/node_modules/@node-red/editor-api/lib/auth/strategies.js:37:21\r\n","stream":"stdout","time":"2022-09-21T18:40:05.537347266Z"}
@MintyTrebor
Copy link
Owner

Why http://voron-klipper.feli-home.drachenkatze.org:7125 in the API field? - That is not a moonraker api code.
You only need an api key if you have enabled it in moonraker:
https://moonraker.readthedocs.io/en/latest/web_api/#authorization

@Drachenkaetzchen
Copy link
Author

Well the field was not really clear what to put in. If it said "API Key" it's obvious, but only "API" is ambiguous and I recommend renaming it.

I have removed the value, so "API" is empty and websocket is "voron-klipper.feli-home.drachenkatze.org:7125". Still the same crash when clicking refresh.

@MintyTrebor
Copy link
Owner

When you refresh do you mean you deployed the flow after the change?
If you enter voron-klipper.feli-home.drachenkatze.org:7125 into your browser do you see something like this?
image

@Drachenkaetzchen
Copy link
Author

No, I click refresh here:

image

Yes, the moonraker status page comes up with that URL.

image

@MintyTrebor
Copy link
Owner

I have not tried it using a FQDN personally.. Do you know the IP & can you change the address to use the IP+Port and test it please.

@Drachenkaetzchen
Copy link
Author

Of course I know the IP, I punched it into the zone file myself ;)

But no luck either. Moonraker has the /25 as trusted_clients, but I don't even see a connection attempt or any error on the log.

Looking at the code the issue seems to come up way before any request is being sent:

https://github.com/MintyTrebor/moonNode/blob/main/MoonNode.js#L24

@MintyTrebor
Copy link
Owner

MintyTrebor commented Sep 21, 2022

I just tested my setup with a FQDN and it works, so that's not the issue at least. Might also be worth deploying the flow, then going back in and refreshing.
Are you able to check the docker can reach that IP in general. Maybe by adding a ping node, or pinging in the docker container shell?

@Drachenkaetzchen
Copy link
Author

Well I don't think any request is actually sent. It crashes when it tries to retrieve the credentials. By crash I mean the exception posted above, which in turn shuts down the node red server.

This is the location which triggers it. https://github.com/MintyTrebor/moonNode/blob/main/MoonNode.js#L24

@MintyTrebor
Copy link
Owner

Just incase can you delete the current connection and add it again. It looks like it still thinks there is a value in the API field

@Drachenkaetzchen
Copy link
Author

As expected, pinging from the container works fine

image

The other way around doesn't, because of the private subnet.

I tried re-adding, the first time it didn't work, the second time it did. Not sure why, though.

I'd suggest to check if mnSvrNode.credentials exists and throw an error so that users don't kill their node red service

@MintyTrebor
Copy link
Owner

Yes. I have just re-created it...Same error msg as you. If it contains a space it thinks it has a value, but then errors. I will update the error trapping and catch that condition.
Thanks for working through it with me.

@Drachenkaetzchen
Copy link
Author

I'm always happy to help when I can!

@MintyTrebor
Copy link
Owner

FYI - I have found the reason why it was failing when you removed/changed the API key... It looks like changing the connection properties requires a deploy before the new values are read. However - If you add a new connection it works without requiring a a deploy, hence the inconsistent behaviour.
Not sure I can do anything about it as is seems to be Node-red default behaviour. I'll put a notice on the screen to warn user to deploy after changing connection paramters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants