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

Throws "KeyError: 0" exceptions when starts app #406

Closed
3 tasks done
rstm-sf opened this issue May 15, 2020 · 4 comments
Closed
3 tasks done

Throws "KeyError: 0" exceptions when starts app #406

rstm-sf opened this issue May 15, 2020 · 4 comments

Comments

@rstm-sf
Copy link

rstm-sf commented May 15, 2020

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere.
  • I have searched in the issue tracker for similar bug reports, including closed ones.
  • I run last and 15.0.1 versions

Description

Throws "KeyError: 0" exceptions when starts app

Steps to Reproduce

$ python --version
Python 3.8.0

$ pip freeze
pkg-resources==0.0.0
pyaes==1.6.1
Pyrogram==0.17.1
PySocks==1.7.1
TgCrypto==1.2.1
from pyrogram import Client

app = Client("client", api_id=API_ID, api_hash='API_HASH')
app.start()

Traceback

Traceback (most recent call last):
  File "untitled.py", line 4, in <module>
    app.start()
  File "./env/lib/python3.8/site-packages/pyrogram/client/client.py", line 827, in start
    is_authorized = self.connect()
  File "./env/lib/python3.8/site-packages/pyrogram/client/client.py", line 261, in connect
    self.load_session()
  File "./env/lib/python3.8/site-packages/pyrogram/client/client.py", line 1505, in load_session
    self.storage.auth_key(Auth(self, self.storage.dc_id()).create())
  File "./env/lib/python3.8/site-packages/pyrogram/session/auth.py", line 256, in create
    raise e
  File "./env/lib/python3.8/site-packages/pyrogram/session/auth.py", line 87, in create
    res_pq = self.send(functions.ReqPqMulti(nonce=nonce))
  File "./env/lib/python3.8/site-packages/pyrogram/session/auth.py", line 65, in send
    return self.unpack(response)
  File "./env/lib/python3.8/site-packages/pyrogram/session/auth.py", line 58, in unpack
    return TLObject.read(b)
  File "./env/lib/python3.8/site-packages/pyrogram/api/core/tl_object.py", line 33, in read
    return objects[int.from_bytes(b.read(4), "little")].read(b, *args)
KeyError: 0
@delivrance
Copy link
Member

Seems like a bad connection. Probably Telegram is blocked in your country or you are behind a proxy of some kind.

@delivrance
Copy link
Member

Also, don't edit the template where it asks specifically to try the latest development version from github.

@rstm-sf
Copy link
Author

rstm-sf commented May 16, 2020

Seems like a bad connection. Probably Telegram is blocked in your country or you are behind a proxy of some kind.

Oh thanks! I forgot about it already :)

closed this

@delivrance, It seems to me that a fix would be a good reason for closing, which gives a more understandable error message. "KeyError: 0" -- this message does not carry useful information to the user. It would be nice if there was a connection issue message :)

Also, don't edit the template where it asks specifically to try the latest development version from github.

Oops, yes, here I was wrong, I apologize

@vaintrub
Copy link

vaintrub commented Apr 16, 2021

Hello! When I start the client in docker, I got the same error but I don't use some proxies and tg is allowed in my country. But not using docker everything is fine :(( What could be the reason?

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

No branches or pull requests

3 participants