bencevans/node-sonos

Listener - EHOSTUNREACH unhandled exception

Closed this issue · 5 comments

Using node-sones' Listener functions with the homebridge-sonos plugin. After running a few days, i do get unhandled exceptions:

events.js:85
throw er; // Unhandled 'error' event
^
Error: connect EHOSTUNREACH
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect as oncomplete

Tried to figure the root cause, but struggling with it still i'm afraid. I believe this is happening upon a sonos speaker loosing network connection, as i'm able to reproduce by unplugging a speakers power, and after a while (approx. 1-3 minutes) the homebridge server dies with the above in the logs. have been trying everything in the homebridge-sonos plugin i could come up with (note - i'm no nodejs expert by no means), but this does not seem to be related to the homebridge-sonos plugin code (which subscribes to groupmgmt events to act upon these; if I deactivate the event subscription in the plugin, this error never occurs. All debug logging when subscription is activated also doesn't provide any indication that anything in the plugin's event subscription handling code is causing this....).

Any potential advice from you node-sones gurus which could help me identify the root cause for this? The only thing i noticed is that the "devListener.on('serviceEvent', function (endpoint, sid, data)" call i'm using (based on the zoneTopologySubscription.js example) doesn't include any err object being returned (errors aren't escalated?)...

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30836296-listener-ehostunreach-unhandled-exception?utm_campaign=plugin&utm_content=tracker%2F276575&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F276575&utm_medium=issues&utm_source=github).

does happen also independent of the event subscription, see "Error: socket hang up" another user reported at nfarina/homebridge-sonos#19... (the version being in use there is the one without the subscription)

Found it (using longjohn). There's an issue with the code in the Listener.prototype._renewServices function, will work on an attempt to resolve (will also require some test runs for several days I suppose) and - in case I believe all good - will submit a pull request.

Awesome thankyou very much!

Hello @fwboettger. Great news.

@fwboettger could you provide us with a little bit more information.

Are you still working on a pull-request or did the issue resolve itself by us updating the dependencies of node-sonos.
The current version got an easier way to listen to events from sonos, maybe you can check it out.

Could you re-open this issue if you think this library still got a bug on the event part?