Skip to content
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

Fail to reconnect #561

Closed
aprilmay opened this issue Nov 10, 2020 · 7 comments
Closed

Fail to reconnect #561

aprilmay opened this issue Nov 10, 2020 · 7 comments
Assignees
Labels

Comments

@aprilmay
Copy link

Some exceptions are not caught on reconnect, and the client enters a "dead" state (note that i use asyncio and websocket transport, i'm not sure about other setup).

In my case, it's usually an error with DNS resolution, which raises a aiohttp.client_exceptions.ClientConnectionError.

A quick workaround is to add the relevant exception type in the try/except block of the _connect_websocket method in the asyncio_client.py file (around line 308).

@miguelgrinberg miguelgrinberg self-assigned this Nov 10, 2020
@aprilmay
Copy link
Author

My bad, the error (and quick fix) is actually in the python-engineio package.

@miguelgrinberg
Copy link
Owner

@aprilmay Yes, that is correct. Would you like to craft the fix yourself?

@aprilmay
Copy link
Author

Sure. A simple git diff @~..@gives:

diff --git a/engineio/asyncio_client.py b/engineio/asyncio_client.py
index 62067b0..1a7de0b 100644
--- a/engineio/asyncio_client.py
+++ b/engineio/asyncio_client.py
@@ -306,7 +306,8 @@ class AsyncClient(client.Client):
                     websocket_url + self._get_url_timestamp(),
                     headers=headers)
         except (aiohttp.client_exceptions.WSServerHandshakeError,
-                aiohttp.client_exceptions.ServerConnectionError):
+                aiohttp.client_exceptions.ServerConnectionError,
+                aiohttp.client_exceptions.ClientConnectionError):
             if upgrade:
                 self.logger.warning(
                     'WebSocket upgrade failed: connection error')

I'm not familiar with github PRs, but i can learn if you want one.

@miguelgrinberg
Copy link
Owner

Thanks!

I'm not familiar with github PRs, but i can learn if you want one.

Only if you want to. I can apply the change myself if you are not interested or don't have time.

@aprilmay
Copy link
Author

Sorry for late reply. It would be nice and more simple if you could apply the patch, then.
Thanks!

@miguelgrinberg
Copy link
Owner

Done

@aprilmay
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants