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

webservice node can crash node-red startup, but easy to work around #35

Closed
emes opened this issue Dec 11, 2019 · 3 comments
Closed

webservice node can crash node-red startup, but easy to work around #35

emes opened this issue Dec 11, 2019 · 3 comments

Comments

@emes
Copy link
Contributor

emes commented Dec 11, 2019

Sending a request with the Webservice node immediately after starting Node-RED consistently results in a crash. This happens because structureData.msInfo is not there yet. Probably related to #12

11 Dec 13:39:20 - [warn] [function:delay] lox not ready, queue messages
11 Dec 13:39:20 - [red] Uncaught Exception:
11 Dec 13:39:20 - TypeError: Cannot read property 'msInfo' of null
    at API.<anonymous> (/data/node_modules/node-red-contrib-loxone/loxone/loxone.js:241:61)
    at API.emit (events.js:198:13)
    at API.EventEmitter.emit (domain.js:448:20)
    at TokenEnc.<anonymous> (/data/node_modules/node-lox-ws-api/lib/API.js:256:14)
    at TokenEnc.emit (events.js:198:13)
    at TokenEnc.EventEmitter.emit (domain.js:448:20)
    at Object.callback (/data/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:204:22)
    at API._message_text (/data/node_modules/node-lox-ws-api/lib/API.js:210:18)
    at Connection.<anonymous> (/data/node_modules/node-lox-ws-api/lib/API.js:114:14)
    at Connection.emit (events.js:198:13)
    at Connection.EventEmitter.emit (domain.js:448:20)
    at Connection.handle_message (/data/node_modules/node-lox-ws-api/lib/Connection.js:136:18)
    at WebSocketConnection.<anonymous> (/data/node_modules/node-lox-ws-api/lib/Connection.js:103:14)
    at WebSocketConnection.emit (events.js:198:13)
    at WebSocketConnection.EventEmitter.emit (domain.js:448:20)
    at WebSocketConnection.processFrame (/data/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /data/node_modules/websocket/lib/WebSocketConnection.js:323:40
    at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.

Same on non-Docker hosts.

Easy workaround is to put a delay node in front of the webservice node, use a status node to monitor the webservice node, and override the delay when the webservice node is not connected. Something like:

if (!msg.status.hasOwnProperty("text") || msg.status.text === "connected") {
    msg.delay = 0;
    msg.flush = true;
} else {
    msg.delay = 60 * 1000;
}

Miniserver is running 10.3.11.25 but first noticed this shortly after msInfo was added. Apologies for not reporting at the time.

@codmpm
Copy link
Owner

codmpm commented Dec 12, 2019

Hey @emes. Thanks for #34, already merged.

I will have a look into this, as I'm currently working on #28. I forked node-lox-ws-api and added error messages.

Regarding your issue I don't think it will be possible to "wait" for the connection to come up, as this could be never (e.g. on erorrs).
But I have to fix that node-red-contrib-loxone will not crash and simply not answer the request. Thus the delay-node workaround will still be needed.

Open to better solutions, though.

Cheers,
Patrik

@codmpm
Copy link
Owner

codmpm commented Dec 13, 2019

fixed in 0.10.3

@codmpm codmpm closed this as completed Dec 13, 2019
@codmpm
Copy link
Owner

codmpm commented Dec 13, 2019

I've also added a log entry, when a webservice is called and structureData(msInfo) is not there. The request will be processed as long as a connection to the miniserver is established.

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