WebThingsIO / thing-url-adapter

Proxy adapter for Web Thing API endpoints
Mozilla Public License 2.0
21 stars 18 forks source link

OUCH! - could not add membership to interface #101

Closed createcandle closed 3 years ago

createcandle commented 3 years ago

I'm working on an addon that creates a wifi hotspot that is segregated from the home wifi network.

Currently enabling it causes the thing-url-adapter to crash continously:

2021-03-22 10:24:55.877 INFO   : thing-url-adapter: Loading add-on thing-url-adapter from /home/pi/.webthings/addons/thing-url-adapter
2021-03-22 10:24:56.044 INFO   : thing-url-adapter: Starting mDNS discovery
2021-03-22 10:24:56.075 INFO   : thing-url-adapter: OUCH! - could not add membership to interface 169.254.185.131 { Error: addMembership EADDRINUSE
2021-03-22 10:24:56.076 INFO   : thing-url-adapter:     at Socket.addMembership (dgram.js:581:11)
2021-03-22 10:24:56.077 INFO   : thing-url-adapter:     at /home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:249:18
2021-03-22 10:24:56.078 INFO   : thing-url-adapter:     at Array.forEach (<anonymous>)
2021-03-22 10:24:56.079 INFO   : thing-url-adapter:     at Socket.<anonymous> (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:247:57)
2021-03-22 10:24:56.080 INFO   : thing-url-adapter:     at Socket.emit (events.js:198:13)
2021-03-22 10:24:56.081 INFO   : thing-url-adapter:     at startListening (dgram.js:128:10)
2021-03-22 10:24:56.082 INFO   : thing-url-adapter:     at state.handle.lookup (dgram.js:249:7)
2021-03-22 10:24:56.083 INFO   : thing-url-adapter:     at process._tickCallback (internal/process/next_tick.js:63:19)
2021-03-22 10:24:56.084 INFO   : thing-url-adapter:   errno: 'EADDRINUSE',
2021-03-22 10:24:56.085 INFO   : thing-url-adapter:   code: 'EADDRINUSE',
2021-03-22 10:24:56.086 INFO   : thing-url-adapter:   syscall: 'addMembership' }
2021-03-22 10:24:57.806 ERROR  : thing-url-adapter: events.js:174
2021-03-22 10:24:57.807 ERROR  : thing-url-adapter:       throw er; // Unhandled 'error' event
2021-03-22 10:24:57.808 ERROR  : thing-url-adapter:       ^
2021-03-22 10:24:57.809 ERROR  : thing-url-adapter: 
2021-03-22 10:24:57.811 ERROR  : thing-url-adapter: Error: send ENETUNREACH 224.0.0.251:5353
2021-03-22 10:24:57.812 ERROR  : thing-url-adapter:     at SendWrap.afterSend [as oncomplete] (dgram.js:467:11)
2021-03-22 10:24:57.813 ERROR  : thing-url-adapter: Emitted 'error' event at:
2021-03-22 10:24:57.814 ERROR  : thing-url-adapter:     at Browser._onError (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/Browser.js:146:8)
2021-03-22 10:24:57.815 ERROR  : thing-url-adapter:     at Object.onceWrapper (events.js:286:20)
2021-03-22 10:24:57.817 ERROR  : thing-url-adapter:     at NetworkInterface.emit (events.js:203:15)
2021-03-22 10:24:57.818 ERROR  : thing-url-adapter:     at NetworkInterface._onError (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:438:8)
2021-03-22 10:24:57.819 ERROR  : thing-url-adapter:     at SendWrap.callback (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:393:50)
2021-03-22 10:24:57.820 ERROR  : thing-url-adapter:     at SendWrap.afterSend [as oncomplete] (dgram.js:472:8)
2021-03-22 10:24:57.829 INFO   : Plugin: thing-url-adapter died, code = 1 restarting after 30000
2021-03-22 10:25:29.012 INFO   : thing-url-adapter: Opening database: /home/pi/.webthings/config/db.sqlite3
2021-03-22 10:25:29.063 INFO   : thing-url-adapter: Ignoring https://raw.githubusercontent.com/WebThingsIO/gateway-addon-ipc-schema/master/schema.json because it has no messageType
2021-03-22 10:25:30.124 INFO   : thing-url-adapter: Ignoring https://raw.githubusercontent.com/WebThingsIO/gateway-addon-ipc-schema/master/messages/definitions.json because it has no messageType
2021-03-22 10:25:31.849 INFO   : thing-url-adapter: Loading add-on thing-url-adapter from /home/pi/.webthings/addons/thing-url-adapter
2021-03-22 10:25:32.029 INFO   : thing-url-adapter: Starting mDNS discovery
2021-03-22 10:25:32.161 ERROR  : thing-url-adapter: events.js:174
2021-03-22 10:25:32.164 ERROR  : thing-url-adapter:       throw er; // Unhandled 'error' event
2021-03-22 10:25:32.165 ERROR  : thing-url-adapter:       ^
2021-03-22 10:25:32.171 ERROR  : thing-url-adapter: 
2021-03-22 10:25:32.172 ERROR  : thing-url-adapter: Error: send ENETUNREACH 224.0.0.251:5353
2021-03-22 10:25:32.173 ERROR  : thing-url-adapter:     at SendWrap.afterSend [as oncomplete] (dgram.js:467:11)
2021-03-22 10:25:32.174 ERROR  : thing-url-adapter: Emitted 'error' event at:
2021-03-22 10:25:32.174 ERROR  : thing-url-adapter:     at Browser._onError (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/Browser.js:146:8)
2021-03-22 10:25:32.175 ERROR  : thing-url-adapter:     at Object.onceWrapper (events.js:286:20)
2021-03-22 10:25:32.176 ERROR  : thing-url-adapter:     at NetworkInterface.emit (events.js:203:15)
2021-03-22 10:25:32.177 ERROR  : thing-url-adapter:     at NetworkInterface._onError (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:438:8)
2021-03-22 10:25:32.178 ERROR  : thing-url-adapter:     at SendWrap.callback (/home/pi/.webthings/addons/thing-url-adapter/node_modules/dnssd/lib/NetworkInterface.js:393:50)
2021-03-22 10:25:32.179 ERROR  : thing-url-adapter:     at SendWrap.afterSend [as oncomplete] (dgram.js:472:8)
2021-03-22 10:25:32.181 INFO   : Plugin: thing-url-adapter died, code = 1 restarting after 30000

I'll look into how I can mitigate this, but thought I'd share early.

benfrancis commented 3 years ago

If you manually change the network configuration of the gateway then things are going to break, that is not surprising.

Also, FWIW your approach of manually editing OS configuration files from an add-on is going to be brittle and platform dependent. I'd be very cautious about allowing that add-on into the add-on directory as it's likely to break people's gateways in ways that are not easily reversible.

Note that we experimented with making the gateway into a Wi-Fi access point/router a couple of years ago using OpenWrt, which required a separate distribution of the gateway with a different base OS, different first time setup UI and different Network Settings UI. We've recently removed all that code since it wasn't a sustainable path with the resources we had available. I really think if you want to change things this drastically you need to fork the gateway repository rather than trying to do it using add-ons.

I'm going to close this issue because this bug is not reproduceable on master and is probably a problem with your add-on, not the gateway.

createcandle commented 3 years ago

I know, back then I even bought that $300 OpenWRT router to try that router-gateway build.

I already fixed this issue as well. It was caused by starting my addon too early, before the network/gateway was settled.

So far the addon is also easily reversible, and doesn't make any changes that a reboot wouldn't remove.

Anyway, this wasn't really an issue so much as a "perhaps someone has a suggestion where I should be looking". But I found it already.