-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled exception for ping task #5182
Comments
Possible solution is create method class WebSocketResponse:
...
async def _ping(self):
try:
await self._writer.ping()
except ConnectionResetError:
pass
def _send_heartbeat(self) -> None:
...
self._loop.create_task(self._ping()) # instead of self._writer.ping() Anyway I can do a PR with a fix :) |
Hi. |
Any update on this? |
I would like to stop seeing these messages in my logs. I figured instead of just a ping I'd provide some concrete code to try to induce chatter. See #7238. It's draft, no doc updates, etc. If it is received well I will do all the pieces of a proper contribution. Thanks for your time. |
I think the previously linked PR looks more promising, as it is attempting to fix the cause of the issue, rather than just hide the error. Not sure why the PR has not been finished off and merged though.. |
is this issue still present as I still get the error: after I cancel asyncio gathered tasks, it looks like it is coming from: |
related issue home-assistant/core#123653 replaces and closes #7238 fixes #5182
related issue home-assistant/core#123653 replaces and closes #7238 fixes #5182
🐞 Describe the bug
Websocket handler with enabled
autoping
option does not handle sudden client disconnection right.When client calls
receive()
method, handler internally creates task withping()
call. If the client disconnects without sending close message, task will not be cancelled which leads us to theConnectionResetError
exception.asyncio
logs it withTask exception was never retrieved
, which is correct, but in this case annoying.💡 To Reproduce
Consider following server/client example.
💡 Expected behavior
Exception should be handled. We can't require
WSMsgType.CLOSE
message from client in all cases, because its disconnection may be caused by network failure.📋 Logs/tracebacks
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
📋 Additional context
Looks like this problem affects
3.7+
versions of aiohttp.The text was updated successfully, but these errors were encountered: