Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.11k stars 214 forks source link

Client doesn't seem to setReady correctly if connection lost: "NoneType attribute has no attribute setReady" #326

Closed Hubcapp closed 1 year ago

Hubcapp commented 4 years ago

Error found in commit 7c9bd596b5ac6fc988ad795cd021216942ad714 from June 10th.

I apparently lost connection & was watching a video with someone for about 8 minutes after they paused & I didn't notice. But the Text "Everyone is Ready" stayed in the top left corner. Probably it should 1. be able to reconnect to the server but 2. let the user know if they are not connected.

Here is a stack trace.

Unhandled error in Deferred:

Traceback (most recent call last):
  File "/home/tyler/code/notMine/syncplay/syncplay/vendor/qt5reactor.py", line 276, in iterate_qt
    self.iterate(delay=delay, fromqt=True)
  File "/home/tyler/code/notMine/syncplay/syncplay/vendor/qt5reactor.py", line 270, in _iterate
    self.runUntilCurrent()
  File "/home/tyler/.local/lib/python3.7/site-packages/twisted/internet/base.py", line 913, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "/home/tyler/.local/lib/python3.7/site-packages/twisted/internet/task.py", line 239, in __call__
    d = defer.maybeDeferred(self.f, *self.a, **self.kw)
--- <exception caught here> ---
  File "/home/tyler/.local/lib/python3.7/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
    result = f(*args, **kw)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 178, in askPlayer
    self._player.askForStatus()
  File "/home/tyler/code/notMine/syncplay/syncplay/players/mpv.py", line 309, in askForStatus
    self._paused if self.fileLoaded else self._client.getGlobalPaused(), self.getCalculatedPosition())
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 241, in updatePlayerStatus
    pauseChange = self._toggleReady(pauseChange, paused)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 305, in _toggleReady
    self.changeReadyState(not self.getPlayerPaused(), manuallyInitiated=False)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 868, in wrapper
    return f(self, *args, **kwds)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 980, in changeReadyState
    self.toggleReady(manuallyInitiated)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 868, in wrapper
    return f(self, *args, **kwds)
  File "/home/tyler/code/notMine/syncplay/syncplay/client.py", line 974, in toggleReady
    self._protocol.setReady(not self.userlist.currentUser.isReady(), manuallyInitiated)
builtins.AttributeError: 'NoneType' object has no attribute 'setReady'

^CException in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/home/tyler/code/notMine/syncplay/syncplay/players/python_mpv_jsonipc/python_mpv_jsonipc.py", line 163, in run
    current_data = self.socket.recv(1024)
ConnectionResetError: [Errno 104] Connection reset by peer
Et0h commented 4 years ago

Thank you for reporting this issue. As far as I can see the root cause is not https://github.com/Syncplay/syncplay/commit/7c9bd596b5ac6fc988ad795cd021216942ad7140 but actually the fact that Syncplay does not check to ensure you are logged in before trying to send various messages to the server. It is a bit late in development to try to change this in Syncplay 1.6.5 because any modifications to address the issue could introduce new bugs, but hopefully this can be fixed in Syncplay 1.6.6.

If you want Syncplay to automatically pause when someone leaves then you should ensure that in Syncplay the 'Play/Pause' option 'Pause when user leaves (e.g. if they are disconnected)' is selected. This feature is explained in https://syncplay.pl/guide/client/ and in the tooltip.

Hubcapp commented 4 years ago

7c9bd59 is just the version I was using; kind of strange phrasing on my part I guess. Thanks for looking into the issue.

albertosottile commented 3 years ago

@Hubcapp Did you see this error again? Have you tried to upgrade to a newer commit/release of Syncplay? Please let us know anything that could be useful to reproduce/debug this issue. Thanks for your time.

Hubcapp commented 3 years ago

This is the kind of bug that's hard to reproduce/debug, because it relies on losing connection to the server. I followed Et0h's advice to automatically pause when someone leaves and since then I've not had a problem.