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

Lookup devices fails #57

Closed
nordish1 opened this issue Mar 23, 2019 · 22 comments
Closed

Lookup devices fails #57

nordish1 opened this issue Mar 23, 2019 · 22 comments
Assignees
Labels
question Further information is requested

Comments

@nordish1
Copy link

When I update the alexa-smart-home-v3-node to search for devices, no devices will be found.
The log shows:

Problem looking up unsername's devices
,getDevices error: TypeError: First argument should be a valid curve name

@coldfire84
Copy link
Owner

Can you confirm Node-RED version you are running?

@nordish1
Copy link
Author

node-red 0.20.2
node-red-contrib-alexa-smart-home 0.4.29

@coldfire84
Copy link
Owner

Can you confirm if this issue persists with Node-RED 0.20.3 (currently running this myself, with the latest version of the nodes)

@nordish1
Copy link
Author

The issue persists with Node-RED 0.20.3

@coldfire84
Copy link
Owner

Thanks, I can't replicate on my production instance. Going to build a fresh Node-RED install and test.
Are you able to revert back to a previous version of the nodes?

@coldfire84
Copy link
Owner

coldfire84 commented Mar 24, 2019

node-red-contrib-alexa-smart-home updated to 0.4.30 / published on npmjs, can you advise if this version shows the same issue.

@nordish1
Copy link
Author

Now my Node-RED container restarts regularly. The log shows the following error:

[error] [alexa-smart-home-v3-conf:e47a58f4.a050c8] TypeError: First argument should be a valid curve name
, at process._tickCallback (internal/process/next_tick.js:161:9)
, at _combinedTickCallback (internal/process/next_tick.js:95:7)
, at Scheduler.drain (/usr/src/node-red/node_modules/when/lib/Scheduler.js:27:9)
, at Scheduler._drain (/usr/src/node-red/node_modules/when/lib/Scheduler.js:62:19)
, at runContinuation1 (/usr/src/node-red/node_modules/when/lib/makePromise.js:804:4)
, at Fulfilled.when (/usr/src/node-red/node_modules/when/lib/makePromise.js:592:4)
, at Pending.run (/usr/src/node-red/node_modules/when/lib/makePromise.js:483:13)
, at tryCatchReject (/usr/src/node-red/node_modules/when/lib/makePromise.js:845:30)
, at start (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:329:33)
, at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:154:40)
, at Object.createNode (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:483:31)
, at new alexaConf (/data/node_modules/node-red-contrib-alexa-smart-home.old/alexa.js:58:9)
, at getDevices (/data/node_modules/node-red-contrib-alexa-smart-home.old/alexa.js:824:31)
, at Object.request (/usr/src/node-red/node_modules/agent-base/patch-core.js:23:20)
, at Object.request (https.js:233:15)
, at Object.request (http.js:39:10)
, at new ClientRequest (_http_client.js:272:16)
, at Agent.addRequest (_http_agent.js:184:10)
, at Agent.createSocket (_http_agent.js:222:26)
, at Object.exports.connect (_tls_wrap.js:1038:48)
, at Object.createSecureContext (_tls_common.js:117:15)
, at Agent.createConnection (https.js:105:22)

And a lot of this:

[warn] [alexa-smart-home-v3:device name] Unable to register device node, account not configured!

@coldfire84
Copy link
Owner

Now my Node-RED container restarts regularly

That's not good :(

Can you confirm how you've installed Node-RED, and importantl;y what version of node.js you are running, when Node-RED starts you'll see some thing like this in the Node-RED log:

24 Mar 22:28:35 - [info] Node-RED version: v0.20.3
24 Mar 22:28:35 - [info] Node.js  version: v8.15.1

I suspect it is Node related, rather than Node-RED/ the update itself.

@coldfire84
Copy link
Owner

Based upon this assumption, I've modified a revision of the nodes to only apply the 'ecdhCurve' request parameter for node.js 8 deployments or newer. This parameter was added fairly recently to address this known issue.

@nordish1, please do let me know the NodeJS version you're running to confirm this is root cause (or discount). Sorry for any inconvenience.

@coldfire84
Copy link
Owner

Did this resolve your issue?

@coldfire84 coldfire84 self-assigned this Mar 26, 2019
@coldfire84 coldfire84 added the question Further information is requested label Mar 26, 2019
@nordish1
Copy link
Author

@coldfire84 Sorry, but I can't check it before weekend

@a011528
Copy link

a011528 commented Mar 28, 2019

+1 - same issue

Node Red: V0.20.3
node-red-contrib-alexa-smart-home: 0.4.31
node.js: 10.15.3

are you saying we need to downgrade to node v8.15?

@coldfire84
Copy link
Owner

Can you share full console logs please.

@RobertHerter
Copy link

RobertHerter commented Mar 28, 2019

Crashing for me also,
fixed it fast with:

const req = https.request(options, (res) => { //console.log('statusCode:', res.statusCode); //console.log('headers:', res.headers); var body='' res.on('data', (d) => { if (res.statusCode == 200) { body = body + d; } else { console.log("Error: getDevices status code: " + res.statusCode); console.log("Error: getDevices returned data: " + res.d); } }); res.on('end', (d) => { var devs = JSON.parse(body); devices[id] = devs; }); });
Looks` like data is coming chunked and res.on is called every time until full body is received.
So JSON.parse(body) is thring an exception causing nodered to crash.

Quick and dirty fix ;-)

@a011528
Copy link

a011528 commented Mar 28, 2019

Update: after several issues and Tests, some feedback.

  1. Devices not showing up!
    a. Added multiple devices on your site and none flow into Node-Red/ palate (alexa Smart home node ) devices (even after refresh)
    b. Cause having more than device on your site, crashes your app causing Node-Red to restart in a loop (see below). Assume its in the JSON file

  2. Deleted all Devices and started again
    a. Adding 1 device with one option, seems to flow correctly and works (no Loop/Crash), device appears in Node-Red
    b. Adding 2 devices cause Node-Red to loop/Crash (same message below)
    c. Editing 1 device with only one feature (i.e. Brightness) –works
    d. Editing 1 device and adding 2 or more features (i.e. Brightness / colour) – Crash/Loop (see below)

#After adding one or more or edit feature service crash / loop

Welcome to Node-RED
28 Mar 12:36:12 - [info] Node-RED version: v0.20.3
28 Mar 12:36:12 - [info] Node.js version: v10.15.3
28 Mar 12:36:12 - [info] Linux 4.14.98-v7+ arm LE
28 Mar 12:36:13 - [info] Loading palette nodes
28 Mar 12:36:17 - [info] Dashboard version 2.14.0 started at /ui
28 Mar 12:36:18 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 12:36:18 - [info] Context store : 'default' [module=memory]
28 Mar 12:36:18 - [info] User directory : /home/pi/.node-red
28 Mar 12:36:18 - [warn] Projects disabled : editorTheme.projects.enabled=false
28 Mar 12:36:18 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 12:36:18 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

28 Mar 12:36:18 - [info] Starting flows
28 Mar 12:36:18 - [info] Started flows
28 Mar 12:36:18 - [info] Server now running at http://127.0.0.1:1880/
28 Mar 12:36:18 - [info] [loxone-miniserver: XXXXXXXXXXXXX] Miniserver connected ( XXX.XXX.XXX.XXX) using Token-Enc
28 Mar 12:36:19 - [info] [loxone-miniserver: XXXXXXXXXXXXX] got structure file 2019-03-26 18:54:01
28 Mar 12:37:27 - [red] Uncaught Exception:
28 Mar 12:37:27 - SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at IncomingMessage.res.on (/home/pi/.node-red/node_modules/node-red-contrib-alexa-smart-home/alexa.js:817:41)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
28 Mar 12:37:29 - [info]
Welcome to Node-RED

28 Mar 12:37:29 - [info] Node-RED version: v0.20.3
28 Mar 12:37:29 - [info] Node.js version: v10.15.3
28 Mar 12:37:29 - [info] Linux 4.14.98-v7+ arm LE
28 Mar 12:37:30 - [info] Loading palette nodes
28 Mar 12:37:34 - [info] Dashboard version 2.14.0 started at /ui
28 Mar 12:37:35 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 12:37:35 - [info] Context store : 'default' [module=memory]
28 Mar 12:37:35 - [info] User directory : /home/pi/.node-red
28 Mar 12:37:35 - [warn] Projects disabled : editorTheme.projects.enabled=false
28 Mar 12:37:35 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 12:37:35 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

28 Mar 12:37:35 - [info] Starting flows
28 Mar 12:37:35 - [info] Started flows
28 Mar 12:37:35 - [info] Server now running at http://127.0.0.1:1880/
28 Mar 12:37:35 - [info] [loxone-miniserver: XXXXXXXXXXXXX] Miniserver connected ( XXX.XXX.XXX.XXX) using Token-Enc
28 Mar 12:37:36 - [info] [loxone-miniserver: XXXXXXXXXXXXX] got structure file 2019-03-26 18:54:01
28 Mar 12:38:44 - [red] Uncaught Exception:
28 Mar 12:38:44 - SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at IncomingMessage.res.on (/home/pi/.node-red/node_modules/node-red-contrib-alexa-smart-home/alexa.js:817:41)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
28 Mar 12:38:46 - [info]
Welcome to Node-RED

28 Mar 12:38:46 - [info] Node-RED version: v0.20.3
28 Mar 12:38:46 - [info] Node.js version: v10.15.3
28 Mar 12:38:46 - [info] Linux 4.14.98-v7+ arm LE
28 Mar 12:38:47 - [info] Loading palette nodes
28 Mar 12:38:51 - [info] Dashboard version 2.14.0 started at /ui
28 Mar 12:38:52 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 12:38:52 - [info] Context store : 'default' [module=memory]
28 Mar 12:38:52 - [info] User directory : /home/pi/.node-red
28 Mar 12:38:52 - [warn] Projects disabled : editorTheme.projects.enabled=false
28 Mar 12:38:52 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 12:38:52 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

28 Mar 12:38:52 - [info] Starting flows
28 Mar 12:38:52 - [info] Started flows
28 Mar 12:38:52 - [info] Server now running at http://127.0.0.1:1880/
28 Mar 12:38:52 - [info] [loxone-miniserver: XXXXXXXXXXXXX] Miniserver connected ( XXX.XXX.XXX.XXX) using Token-Enc
28 Mar 12:38:53 - [info] [loxone-miniserver: XXXXXXXXXXXXX] got structure file 2019-03-26 18:54:01
28 Mar 12:38:53 - [red] Uncaught Exception:
28 Mar 12:38:53 - SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at IncomingMessage.res.on (/home/pi/.node-red/node_modules/node-red-contrib-alexa-smart-home/alexa.js:817:41)
at IncomingMessage.emit (events.js:189:13)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
28 Mar 12:38:55 - [info]
Welcome to Node-RED

28 Mar 12:38:55 - [info] Node-RED version: v0.20.3
28 Mar 12:38:55 - [info] Node.js version: v10.15.3
28 Mar 12:38:55 - [info] Linux 4.14.98-v7+ arm LE
28 Mar 12:38:57 - [info] Loading palette nodes
28 Mar 12:39:01 - [info] Dashboard version 2.14.0 started at /ui
28 Mar 12:39:01 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 12:39:01 - [info] Context store : 'default' [module=memory]
28 Mar 12:39:01 - [info] User directory : /home/pi/.node-red
28 Mar 12:39:01 - [warn] Projects disabled : editorTheme.projects.enabled=false
28 Mar 12:39:01 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 12:39:01 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

Welcome to Node-RED

28 Mar 13:04:36 - [info] Node-RED version: v0.20.3
28 Mar 13:04:36 - [info] Node.js version: v10.15.3
28 Mar 13:04:36 - [info] Linux 4.14.98-v7+ arm LE
28 Mar 13:04:37 - [info] Loading palette nodes
28 Mar 13:04:41 - [info] Dashboard version 2.14.0 started at /ui
28 Mar 13:04:42 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 13:04:42 - [info] Context store : 'default' [module=memory]
28 Mar 13:04:42 - [info] User directory : /home/pi/.node-red
28 Mar 13:04:42 - [warn] Projects disabled : editorTheme.projects.enabled=false
28 Mar 13:04:42 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 13:04:42 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

28 Mar 13:04:42 - [info] Starting flows
28 Mar 13:04:42 - [info] Started flows
28 Mar 13:04:43 - [info] Server now running at http://127.0.0.1:1880/
28 Mar 13:04:43 - [info] [loxone-miniserver: XXXXXXXXXXXXX] Miniserver connected ( XXX.XXX.XXX.XXX) using Token-Enc
28 Mar 13:04:43 - [info] [loxone-miniserver: XXXXXXXXXXXXX] got structure file 2019-03-26 18:54:01
28 Mar 13:04:43 - [red] Uncaught Exception:
28 Mar 13:04:43 - SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at IncomingMessage.res.on (/home/pi/.node-red/node_modules/node-red-contrib-alexa-smart-home/alexa.js:817:41)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.

@coldfire84
Copy link
Owner

Thanks - I have now replicated - there are two sets of changes required:

    if (semver.gte(process.version, '8.6.0') && tls.DEFAULT_ECDH_CURVE === 'prime256v1') {
        tls.DEFAULT_ECDH_CURVE = 'auto';
    }

And the changes mentioned by @RobertHerter . I am testing these now and will confirm once working npm released.

@coldfire84
Copy link
Owner

You can now test with version 0.4.42

@RobertHerter
Copy link

with 0.4.42 [node-red-contrib-alexa-smart-home/alexa] Error: Cannot find module 'semver' (line:24)

@coldfire84
Copy link
Owner

Crashing for me also,
fixed it fast with:

const req = https.request(options, (res) => { //console.log('statusCode:', res.statusCode); //console.log('headers:', res.headers); var body='' res.on('data', (d) => { if (res.statusCode == 200) { body = body + d; } else { console.log("Error: getDevices status code: " + res.statusCode); console.log("Error: getDevices returned data: " + res.d); } }); res.on('end', (d) => { var devs = JSON.parse(body); devices[id] = devs; }); });
Looks` like data is coming chunked and res.on is called every time until full body is received.
So JSON.parse(body) is thring an exception causing nodered to crash.

Quick and dirty fix ;-)

Thanks for this - this was a result of me moving away from "request" library to "https" - I've integrated your changes.

"Request" library continuously generates the TLS/ curve errors.

@a011528
Copy link

a011528 commented Mar 28, 2019

@coldfire84 on v4.38 - seems solved now, can add multiple devices / features without crash - will test further. Is v4.42 npm or via pallet ?

@coldfire84
Copy link
Owner

with 0.4.42 [node-red-contrib-alexa-smart-home/alexa] Error: Cannot find module 'semver' (line:24)

@RobertHerter I have set a depends on semver 6.0.0 in version 0.4.43 (are you using nodered "lite" install? My fresh install of nodered docker doesn't generate this issue).

@RobertHerter
Copy link

with 0.4.42 [node-red-contrib-alexa-smart-home/alexa] Error: Cannot find module 'semver' (line:24)

@RobertHerter I have set a depends on semver 6.0.0 in version 0.4.43 (are you using nodered "lite" install? My fresh install of nodered docker doesn't generate this issue).

@coldfire84 using nodered on raspi installed via npm, installing semver globaly fixed it, lookes like missing in dependencies

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

No branches or pull requests

4 participants