dhleong / playactor

play around with your playstation devices
146 stars 12 forks source link

Error: Unexpected discovery message #46

Closed kopiro closed 2 years ago

kopiro commented 2 years ago

Hey; I've implemented your library in https://github.com/kopiro/homebridge-playstation, and sometimes I'm getting:

Error: Unexpected discovery message:
    at Object.parseMessage (/usr/lib/node_modules/homebridge-playstation/node_modules/playactor/dist/discovery/messages.js:30:19)
    at Socket.<anonymous> (/usr/lib/node_modules/homebridge-playstation/node_modules/playactor/dist/discovery/udp.js:114:39)
    at Socket.emit (node:events:402:35)
    at UDP.onMessage (node:dgram:939:8)

This happens after connection.close() has been called and we call Device::withId().discover() again;

The weird thing is that this exception goes through the entire main thread and causes homebridge to crash

dhleong commented 2 years ago

Interesting. Not sure what's sending that invalid message, but we should definitely not crash. Should be easy enough to fix, just need to log and skip un-parseable messages in UdpDiscoveryNetworkFactory....

kopiro commented 2 years ago

I may think this problem could happen whenever you do Device::withId() and immediately after you call .openConnection() WITHOUT calling .discover()

Solved it here: https://github.com/kopiro/homebridge-playstation/blob/master/src/playstationAccessory.ts#L99

kopiro commented 2 years ago

@dhleong https://github.com/dhleong/playactor/pull/49

dhleong commented 2 years ago

Fixed by #49 thanks!