kopiro / homebridge-playstation

Playstation integration for Homebridge / HOOBS.
Apache License 2.0
97 stars 9 forks source link

setOn is locked #37

Closed awesole closed 1 year ago

awesole commented 2 years ago

hi everyone, thank you for the work on the plugin.

im having 1 issue with it.

when ps5 is in sleep mode, plugin working fine for me, but when PS5 its turned on, terminal showing me.

(node:2426) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit (Use node --trace-warnings ... to show where the warning was created)

and then I can't do nothing. setOn is locked and then only way its manually.

also Registration error: 403: Forbidden: Remote is already in use

it will be possible adding a button to totally turn off the PS5?

Regards

lorenzomigliorero commented 1 year ago

Same issue

valerioceniccola commented 1 year ago

same issue for me

briancrink commented 1 year ago

Same Issue.

kopiro commented 1 year ago

Hello everyone, the setOn is locked is a preventive timing measure to make sure that the library that we use underneath and the communication with the Playstation works correctly.

What you're seeing then it may be happening because you're just "testing" the plugin and hammering the Playstation with burst of connections, and not using it like you should on a daily basis; something like an Heisenbug.

I've been using the plugin myself for many months now, and you can rest assured that unless you're hammering it, it should do the job.

Let me explain more technically: I observed many errors when trying to switch on/off the console via RemotePlay in a short burst of time; this is happening because the opening of the RemotePlay connection takes some time (is not persistent, as it won't be needed for this feature) - therefore whenever you want to switch on/off, we open a RemotePlay connection, send command and close.

Because this is happening over the Internet, negotiating the initial connection may take sometime; therefore to avoid having these errors and making sure that we don't overload the Playstation, whenever you turn the Playstation on/off via HomeKit, I've a put a 20s timeout that, in case of successful connection it will be released "immediately".

How much immediately really depends on many factor, but what I observed is around 6s to open the connection, send the command, cleanup resource and close connection.

Try it yourself: switch the Playstation On via HomeKit - wait around ~20s - and then try to switch it off; everything should work as expected.

kopiro commented 1 year ago

What I can try to do is explain this better is the error-message so that people are aware of this limitation :)

https://github.com/kopiro/homebridge-playstation/commit/b1d2d839199a895fb596054089a0e52f4353d281

briancrink commented 1 year ago

Hello everyone, the setOn is locked is a preventive timing measure to make sure that the library that we use underneath and the communication with the Playstation works correctly.

What you're seeing then it may be happening because you're just "testing" the plugin and hammering the Playstation with burst of connections, and not using it like you should on a daily basis; something like an Heisenbug.

I've been using the plugin myself for many months now, and you can rest assured that unless you're hammering it, it should do the job.

Let me explain more technically: I observed many errors when trying to switch on/off the console via RemotePlay in a short burst of time; this is happening because the opening of the RemotePlay connection takes some time (is not persistent, as it won't be needed for this feature) - therefore whenever you want to switch on/off, we open a RemotePlay connection, send command and close.

Because this is happening over the Internet, negotiating the initial connection may take sometime; therefore to avoid having these errors and making sure that we don't overload the Playstation, whenever you turn the Playstation on/off via HomeKit, I've a put a 20s timeout that, in case of successful connection it will be released "immediately".

How much immediately really depends on many factor, but what I observed is around 6s to open the connection, send the command, cleanup resource and close connection.

Try it yourself: switch the Playstation On via HomeKit - wait around ~20s - and then try to switch it off; everything should work as expected.

Thank you for clarifying. It's helpful for users to understand the limitations of the plugin so to not label it as an issue.

Perhaps, it would be resourceful to add the limitations to README.md :)