Search code examples
python-3.xwebsocketpython-asyncioaiohttp

aiohttp websocket EOfStream handling


I'm connecting to a websocket endpoint using aiohttp's default WebsocketProtocol and out of the blue (after some time and multiple infinite loop iterations) I always get WSMsgType.ERROR with EofStream as data. To my understanding, this should not happen. I tried researching how to deal with this but have been relatively unsuccessful. Should I just close and reconnect to the endpoint? Is there a way to ensure this doesn't happen? Should I implement a specific handling algorithm?


Solution

  • It means connection closed by peer. Internet is unstable transport, you should always be prepared to such situations. Usually reconnection helps in cases like this.