AlCalzone/ioBroker.tradfri

node 18.0 - Discovering the gateway automatically fails

Grothesk242 opened this issue · 5 comments

With node18 the autodiscovery of the gateway fails.
Log shows:

2022-04-20 20:31:46.067  - info: tradfri.0 (225131) starting. Version 3.1.2 in /opt/iobroker/node_modules/iobroker.tradfri, node: v18.0.0, js-controller: 4.0.23
2022-04-20 20:31:46.253  - info: tradfri.0 (225131) Discovering the gateway automatically...
2022-04-20 20:31:46.261  - error: tradfri.0 (225131) unhandled promise rejection:No available interfaces.
> stack: Error: No available interfaces.
    at EventEmitter.init [as initServer] (/opt/iobroker/node_modules/mdns-server/index.js:38:31)
    at /opt/iobroker/node_modules/node-tradfri-client/build/lib/discovery.js:71:14
    at new Promise (<anonymous>)
    at discoverGateway (/opt/iobroker/node_modules/node-tradfri-client/build/lib/discovery.js:30:12)
    at Object.ready (/opt/iobroker/node_modules/iobroker.tradfri/build/main.js:75:81)
2022-04-20 20:31:46.263  - info: tradfri.0 (225131) Terminated (ADAPTER_REQUESTED_TERMINATION): unhandled promise rejection
2022-04-20 20:31:46.264  - error: tradfri.0 (225131) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2022-04-20 20:31:46.265  - error: tradfri.0 (225131) unhandled promise rejection: No available interfaces.
2022-04-20 20:31:46.266  - error: tradfri.0 (225131) Error: No available interfaces.
    at EventEmitter.init [as initServer] (/opt/iobroker/node_modules/mdns-server/index.js:38:31)
    at /opt/iobroker/node_modules/node-tradfri-client/build/lib/discovery.js:71:14
    at new Promise (<anonymous>)
    at discoverGateway (/opt/iobroker/node_modules/node-tradfri-client/build/lib/discovery.js:30:12)
    at Object.ready (/opt/iobroker/node_modules/iobroker.tradfri/build/main.js:75:81)
2022-04-20 20:31:46.266  - error: tradfri.0 (225131) No available interfaces.
2022-04-20 20:31:46.854  - error: host.chet instance system.adapter.tradfri.0 terminated by request of the instance itself and will not be restarted, before user restarts it.
2022-04-20 20:31:46.855  - info: host.chet Do not restart adapter system.adapter.tradfri.0 because desired by instance

When autodiscovery is disabled the adapter starts without any issue.

I can't seem to install v18 on my system right now. Can you please post the output of this command on node 16 and 18?

node -p "os.networkInterfaces()"

This is a diff of node16 vs node18.
Full output removed due to privacy concerns... :-D

echad@chet:~ $ diff node16 node18
6c6
<       family: 'IPv4',
---
>       family: 4,
14c14
<       family: 'IPv6',
---
>       family: 6,
25c25
<       family: 'IPv4',
---
>       family: 4,
33c33
<       family: 'IPv6',
---
>       family: 6,
42c42
<       family: 'IPv6',
---
>       family: 6,
53c53
<       family: 'IPv4',
---
>       family: 4,
61c61
<       family: 'IPv6',
---
>       family: 6,
70c70
<       family: 'IPv6',
---
>       family: 6,
81c81
<       family: 'IPv4',
---
>       family: 4,
89c89
<       family: 'IPv6',
---
>       family: 6,
98c98
<       family: 'IPv6',
---
>       family: 6,
echad@chet:~ $

Can you test the linked PR?

cd /opt/iobroker
npm i AlCalzone/ioBroker.tradfri#node18

Can confirm patch is working.
Instance restart is clean with 'Autodiscovery' enabled.
Do you think that your patch may also help with this issue:
iobroker-community-adapters/ioBroker.nuki-extended#226
The nuki bridge is not being discovered, similar to the tradfri gateway .

2022-04-23 09:06:23.797  - info: tradfri.0 (14160) starting. Version 3.1.2 in /opt/iobroker/node_modules/iobroker.tradfri, node: v18.0.0, js-controller: 4.0.23
2022-04-23 09:06:23.982  - info: tradfri.0 (14160) Discovering the gateway automatically...
2022-04-23 09:06:24.080  - info: tradfri.0 (14160) Found gateway gw-a0bb3bf87ce8 at 192.168.178.42
2022-04-23 09:06:26.116  - info: tradfri.0 (14160) got all devices: [65630,65579,65583,65580,65571,65634,65635,65633,65563,65613,65557,65572,65576,65558,65643,65631,65642,65641,65581,65603,65626,65629,65552,65628,65627,65637,65636,65610,65644,65639,65612,65560,65584,65638,65582,65632,65585,65575,65577]
2022-04-23 09:06:26.707  - info: tradfri.0 (14160) received all devices
2022-04-23 09:06:26.725  - info: tradfri.0 (14160) got all groups: [131091,131089,131090,131084,131106,131100,131105,131104,131082,131085,131094]
2022-04-23 09:06:27.214  - info: tradfri.0 (14160) got all scenes in group 131082: []
2022-04-23 09:06:27.233  - info: tradfri.0 (14160) got all scenes in group 131084: []
2022-04-23 09:06:27.267  - info: tradfri.0 (14160) got all scenes in group 131085: []
2022-04-23 09:06:27.285  - info: tradfri.0 (14160) got all scenes in group 131089: []
2022-04-23 09:06:27.331  - info: tradfri.0 (14160) got all scenes in group 131090: []
2022-04-23 09:06:27.377  - info: tradfri.0 (14160) got all scenes in group 131091: []
2022-04-23 09:06:27.422  - info: tradfri.0 (14160) got all scenes in group 131094: [196671]
2022-04-23 09:06:27.455  - info: tradfri.0 (14160) got all scenes in group 131100: []
2022-04-23 09:06:27.489  - info: tradfri.0 (14160) got all scenes in group 131104: []
2022-04-23 09:06:27.534  - info: tradfri.0 (14160) got all scenes in group 131105: []
2022-04-23 09:06:27.553  - info: tradfri.0 (14160) got all scenes in group 131106: []
2022-04-23 09:06:27.598  - info: tradfri.0 (14160) received all groups and scenes
2022-04-23 09:06:26.707  - info: tradfri.0 (14160) received all devices
2022-04-23 09:06:26.725  - info: tradfri.0 (14160) got all groups: [131091,131089,131090,131084,131106,131100,131105,131104,131082,131085,131094]
2022-04-23 09:06:27.214  - info: tradfri.0 (14160) got all scenes in group 131082: []

It could be the same issue, if the nuki bridge is also discovered with mDNS.

I'll wait for the upstream library to release the patch and finalize this then. Thanks for testing.