2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 04:48:06 +00:00

Handle TCP server errors

This commit is contained in:
Dan 2018-02-18 20:33:33 +01:00
parent 15561d19d5
commit 02da3fe947

View File

@ -337,7 +337,10 @@ class Session:
while True:
packet = self.connection.recv()
if packet is None or (len(packet) == 4 and Int.read(BytesIO(packet)) == -404):
if packet is None or len(packet) == 4:
if packet:
log.warning("Server sent \"{}\"".format(Int.read(BytesIO(packet))))
if self.is_connected.is_set():
Thread(target=self.restart, name="RestartThread").start()
break