mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-28 00:56:19 +00:00
Don't throw errors if auth key creation fails; try again instead
This commit is contained in:
parent
87b2c4b1e7
commit
cbcb1c78c4
@ -31,9 +31,6 @@ from .internals import MsgId, DataCenter
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO: When using TCP connection mode, the server may close it at any time, causing the Auth key creation to fail
|
||||
# The above is true when dealing with temporary keys, although for perm keys it didn't happened, yet.
|
||||
|
||||
class Auth:
|
||||
CURRENT_DH_PRIME = int(
|
||||
"C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F"
|
||||
@ -79,6 +76,11 @@ class Auth:
|
||||
https://core.telegram.org/mtproto/auth_key
|
||||
https://core.telegram.org/mtproto/samples-auth_key
|
||||
"""
|
||||
|
||||
# The server may close the connection at any time, causing the auth key creation to fail.
|
||||
# If that happens, just try again until it succeed.
|
||||
while True:
|
||||
try:
|
||||
log.info("Start creating a new auth key on DC{}".format(self.dc_id))
|
||||
|
||||
self.connection.connect()
|
||||
@ -240,7 +242,10 @@ class Auth:
|
||||
set_client_dh_params_answer.__class__.__name__
|
||||
)
|
||||
)
|
||||
|
||||
self.connection.close()
|
||||
|
||||
except: # TODO: Too broad exception clause
|
||||
log.warning("Auth key creation failed. Let's try again.")
|
||||
continue
|
||||
else:
|
||||
return auth_key
|
||||
finally:
|
||||
self.connection.close()
|
||||
|
Loading…
Reference in New Issue
Block a user