Closed amorphousWaste closed 1 year ago
I am facing this exact issue, too, and would love to know what the way forward is. I can't really follow the connect/run command/disconnect pattern, as I need to handle scene change events from OBS. What would be really great would be if there was some sort of 'obs dropped the connection' (on_disconnect?) event that I could handle gracefully instead of the unhandled connection just blowing me away. Thanks!
there is:
from obswebsocket import obsws, events
def on_exit(message):
# your function here
pass
ws = obsws("...", "...", "...")
ws.register(on_exit, events.Exiting)
What I would love to know, is how would one reconnect after such event? Calling ws.connect seems to cause ConnectionFailure
on_exit doesn't get invoked - your script crashes :-(
Fixed on master. There is an example here: https://github.com/Elektordi/obs-websocket-py/blob/master/samples/reconnect.py
I have a script that maintains a persistent connection to OBS by calling
ws.connect()
, continuing to do whatever, and then callingws.disconnect()
on close. If OBS is closed before the script finishes, it crashes the script. Is there a way to handle losing the connection to OBS? It looks like the error is happening in another thread and I can't simply wrap it in atry-except
. It also looks like there is already an exception handler incore.py
that should handle this, but isn't.This is the traceback:
Should I not be maintaining a persistent connection and using a reconnect, run command, disconnect pattern?
Any help would be greatly appreciated. Thank you.