Skip to content

Commit 1c2333a

Browse files
committed
work around bad frame disconnect
1 parent f56b13f commit 1c2333a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- ext.eventsub
1818
- Bug fixes
1919
- Fixed a crash where a Future could be None, causing unintentional errors.
20+
- Special-cased a restart when a specific known bad frame is received.
2021

2122

2223
2.8.2

twitchio/ext/eventsub/websocket.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,14 @@ async def pump(self) -> None:
209209
await self.connect()
210210
return
211211

212-
except TypeError as e:
212+
except TypeError as e:
213213
logger.warning(f"Received bad frame: {e.args[0]}")
214214

215+
if e.args[0] is None: # websocket was closed, reconnect
216+
logger.info("Known bad frame, restarting connection")
217+
await self.connect()
218+
return
219+
215220
except Exception as e:
216221
logger.error("Exception in the pump function!", exc_info=e)
217222
raise

0 commit comments

Comments
 (0)