Telethon icon indicating copy to clipboard operation
Telethon copied to clipboard

telethon.errors.rpcerrorlist.AuthKeyUnregisteredError: The key is not registered in the system (caused by GetDialogsRequest)

Open CastroNaLodke opened this issue 2 years ago • 7 comments

Checklist

  • [x] The error is in the library's code, and not in my own.
  • [x] I have searched for this issue before posting it and there isn't a duplicate.
  • [x] I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip and triggered the bug in the latest version.

image

Good afternoon! Already contacted you personally, waiting for a solution to the problem with "telethon.errors.rpcerrorlist.AuthKeyUnregisteredError: The key is not registered in the system (caused by GetDialogsRequest) "

CastroNaLodke avatar Feb 07 '22 04:02 CastroNaLodke

I have the same problem since 5 feb

oilbarrel avatar Feb 07 '22 09:02 oilbarrel

I have the same problem. Moreover, if you do not enter the phone nouber, but restart the program, it work for a while, then it appears again. I use version 1.24.0/

MaxDaskin avatar Feb 07 '22 10:02 MaxDaskin

same problem, spawning at random time

kkein16 avatar Feb 07 '22 11:02 kkein16

If anyone has any specific reasons why this may be happening, please telegraph me at @lovgraa. lonami has already passed the information on.

CastroNaLodke avatar Feb 07 '22 11:02 CastroNaLodke

I have a similar problem since some days now. The error appears at random times, usually after the client is running for some longer time more and more often. My code looks like this (simplified):

client = TelegramClient(label, api_id, api_hash)
try:
    await client.start()
except Exception as e:
    logging.warning(f"client.start() >-> {e}\n{traceback.format_exc()}")

async for message in client.iter_messages(**kwargs):
    ...

Sometimes the exception is thrown when executing start(), which is not a big problem, since i handle it:

client.start() >-> Connection not initialized (caused by GetUsersRequest)
Traceback (most recent call last):
File "/.../telegram.py", line X
  await self.client.start(
File "/.../.local/lib/python3.9/site-packages/telethon/client/auth.py", line 146, in _start
  me = await self.get_me()
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 161, in get_me
  me = (await self(
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 30, in __call__
  return await self._call(self._sender, request, ordered=ordered)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 84, in _call
  result = await future
telethon.errors.rpcerrorlist.ConnectionNotInitedError: Connection not initialized (caused by GetUsersRequest)

But sometimes the exception is thrown after the connect at some random position in my telethon code:

File "/.../telegram.py", line X
  async for message in client.iter_messages(**kwargs):
File "/.../.local/lib/python3.9/site-packages/telethon/requestiter.py", line 74, in __anext__
  if await self._load_next_chunk():
File "/.../.local/lib/python3.9/site-packages/telethon/client/messages.py", line 184, in _load_next_chunk
F  r = await self.client(self.request)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 30, in __call__
  return await self._call(self._sender, request, ordered=ordered)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 84, in _call
    result = await future
telethon.errors.rpcerrorlist.ConnectionNotInitedError: Connection not initialized (caused by GetHistoryRequest)

I started to handle the exception everywhere in my code now, but its annoying, because its appears more and more often after a longer execution time of my client.

p.s. The title of this issue is not matching the error in the screenshot?

mi01 avatar Feb 07 '22 14:02 mi01

I have a similar problem since some days now. The error appears at random times, usually after the client is running for some longer time more and more often. My code looks like this (simplified):

client = TelegramClient(label, api_id, api_hash)
try:
    await client.start()
except Exception as e:
    logging.warning(f"client.start() >-> {e}\n{traceback.format_exc()}")

async for message in client.iter_messages(**kwargs):
    ...

Sometimes the exception is thrown when executing start(), which is not a big problem, since i handle it:

client.start() >-> Connection not initialized (caused by GetUsersRequest)
Traceback (most recent call last):
File "/.../telegram.py", line X
  await self.client.start(
File "/.../.local/lib/python3.9/site-packages/telethon/client/auth.py", line 146, in _start
  me = await self.get_me()
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 161, in get_me
  me = (await self(
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 30, in __call__
  return await self._call(self._sender, request, ordered=ordered)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 84, in _call
  result = await future
telethon.errors.rpcerrorlist.ConnectionNotInitedError: Connection not initialized (caused by GetUsersRequest)

But sometimes the exception is thrown after the connect at some random position in my telethon code:

File "/.../telegram.py", line X
  async for message in client.iter_messages(**kwargs):
File "/.../.local/lib/python3.9/site-packages/telethon/requestiter.py", line 74, in __anext__
  if await self._load_next_chunk():
File "/.../.local/lib/python3.9/site-packages/telethon/client/messages.py", line 184, in _load_next_chunk
F  r = await self.client(self.request)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 30, in __call__
  return await self._call(self._sender, request, ordered=ordered)
File "/.../.local/lib/python3.9/site-packages/telethon/client/users.py", line 84, in _call
    result = await future
telethon.errors.rpcerrorlist.ConnectionNotInitedError: Connection not initialized (caused by GetHistoryRequest)

I started to handle the exception everywhere in my code now, but its annoying, because its appears more and more often after a longer execution time of my client.

p.s. The title of this issue is not matching the error in the screenshot?

The title is matching the error. There're 2 errors:

  1. telethon.errors.rpcerrorlist.AuthKeyUnregisteredError: The key is not registered in the system
  2. telethon.errors.rpcerrorlist.ConnectionNotInitedError: Connection not initialized

1st one appears more often in my case. Restarting the session usually helps, but sometimes the session cannot be started after this errors.

oilbarrel avatar Feb 07 '22 17:02 oilbarrel

Update: It's been 2 hours since I got this error on 40 sessions. Somehow self-corrected, it is not clear, but the topic is still open, until the full clarification of the circumstances.

Up. I haven't received this error for a day, it's strange.

CastroNaLodke avatar Feb 07 '22 19:02 CastroNaLodke

AuthKeyUnregisteredError means the account is no longer logged-in, for whatever reason. This is not something the library can really fix, so I'm closing the issue. The user simply has to login.

Lonami avatar Sep 20 '22 16:09 Lonami