File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ class ChromecastConnectionError(PyChromecastError):
1111 """When a connection error occurs within PyChromecast."""
1212
1313
14+ class ChromecastConnectionClosed (PyChromecastError ):
15+ """When a connection was closed by remote device."""
16+
17+
1418class PyChromecastStopped (PyChromecastError ):
1519 """Raised when a command is invoked while the Chromecast's socket_client
1620 is stopped.
Original file line number Diff line number Diff line change 3333from .dial import get_host_from_service
3434from .error import (
3535 ChromecastConnectionError ,
36+ ChromecastConnectionClosed ,
3637 ControllerNotRegistered ,
3738 NotConnected ,
3839 PyChromecastStopped ,
@@ -619,6 +620,15 @@ def _run_once(self) -> int:
619620 if self .stop .is_set ():
620621 return 1
621622 raise
623+ except ChromecastConnectionClosed as exc :
624+ self ._force_recon = True
625+ self .logger .debug (
626+ "[%s(%s):%s] %s" ,
627+ self .fn or "" ,
628+ self .host ,
629+ self .port ,
630+ exc ,
631+ )
622632 except socket .error as exc :
623633 self ._force_recon = True
624634 self .logger .error (
@@ -817,7 +827,7 @@ def _read_bytes_from_socket(self, msglen: int) -> bytes:
817827 try :
818828 chunk = self .socket .recv (min (msglen - bytes_recd , 2048 ))
819829 if chunk == b"" :
820- raise socket . error ( "socket connection broken " )
830+ raise ChromecastConnectionClosed ( "Connection was closed by remote " )
821831 chunks .append (chunk )
822832 bytes_recd += len (chunk )
823833 except TimeoutError :
You can’t perform that action at this time.
0 commit comments