Visitar URL original
There is no way to stop the auto-reconnect loop · Issue #201 · pyrogram/pyrogram · GitHub
The Wayback Machine - https://web.archive.org/web/20201210054921/https://github.com/pyrogram/pyrogram/issues/201
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

There is no way to stop the auto-reconnect loop #201

Open
minidron opened this issue Jan 12, 2019 · 2 comments
Open

There is no way to stop the auto-reconnect loop #201

minidron opened this issue Jan 12, 2019 · 2 comments

Comments

@minidron
Copy link

@minidron minidron commented Jan 12, 2019

If set wrong proxy settings or proxy server is down, app.start() stuck in a loop.

pyrogram/session/session.py

except (OSError, TimeoutError, Error):
    self.stop()

TimeoutError not break while.

Maybe it should be like this?

except (OSError, TimeoutError, Error) as e:
    self.stop()
    raise e
@delivrance
Copy link
Member

@delivrance delivrance commented Jan 13, 2019

@minidron Hi. This is normal behavior; the idea behind is to keep trying reconnecting indefinitely in order to ensure a client is always connected in case of temporary network issues.

With the DisconnectHandler you are able to change a proxy (usually cycle through a list of them) on disconnections. Pyrogram will always try to connect up to 3 times each loop before calling your disconnect handler callback, and then continues.

It now occurs to me that there's no way to gracefully stop a client, if we wanted to, in a case like yours. I'm thinking about adding something like client.stop_reconnection() to be called inside a DisconnectHandler which will signal Pyrogram to stop trying reconnecting and finally freeing app.start(). What do you think? If you have any other ideas feel free to suggest.

@delivrance delivrance changed the title Connection stuck in a loop There is no way to stop the auto-reconnect loop Jan 13, 2019
@minidron
Copy link
Author

@minidron minidron commented Jan 13, 2019

@delivrance Hi. Thanks. I thinking client.stop_reconnection() is good idea. Maybe default behavior without reconnect and add client.reconnect() ? This is more predictable behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.