Hi!
When I attempt to download a media from another DC, rather than on which I logged in, I get an error
Read RPC error: (RPCError(...), 'The file to be accessed is currently stored in a different data center (#X).')
and after an error
Read RPC error: (RPCError(...), 'The key is not registered in the system.')
After which the data no longer come. When i restart and use the session file, the same error occurs about the not registered key. It only helps to delete the session file.
What version are you using? It should now be possible to work with different datacenters.
Read RPC error: (RPCError(...), 'The key is not registered in the system.')
I'm aware of this, it's like if the *.session file is corrupted after receiving errors on login, it's a bit like #7. Session file gets corrupted.
I use 0.8 version installed via pip.
I wonder if it has something to do with:
The problem is because wrong timezone or clock settings on my operating system
As @realbardia mentioned. Maybe some request is re-sent but the time has changed too much by then? Though, this was not the (only) issue.
It seems like they fixed it by adding these lines (it took me a while to find a commit close to the date the issue was fixed!), but I already handle DC switching, so I'm not sure what the issue can be.
Other people with this issue solved it by deleting the .telegram-cli folder, which is the equivalent to deleting the *.session file for Telethon. But… that should not be the right way to fix the problem.
Maybe a longer log could provide some more insight. Not sure.
I reproduced the bug, here is the log. Note this line though, for some reason I seem to be creating a new session for which I don't have the key registered.
I'm having the same issue as OP. Any workarounds, @Lonami ?
Any workarounds
Nope, I'm still clueless. I'm not sure how we can handle this, and all help is appreciated.
Any way to maybe manually connect to the correct DC before downloading the file? I'm kinda new to the Telegram API, so I don't know if that's a possibility.
Any way to maybe manually connect to the correct DC before downloading the file?
No, not before downloading the file but at the beginning, possible by changing this line. However, it will reconnect you as soon as a InvalidDCError happens, so you would have to change more things.
I see. I noticed that the error is triggered by using invoke() for this GetFileRequest, and inside invoke() it tries to reconnect to another DC because of the error. Isn't triggering that sudden reconnect in the middle of the execution the cause of this problem?
Shouldn't this reconnection be made more safely before invoking the GetFileRequest by using the dc_id parameter of the file or something?
I'm not sure if it's necessary to reconnect or if it's possible to create a second connection just to download the file, as I'm new to the whole Telegram API, but just my 2 cents.
or if it's possible to create a second connection just to download the file
This is the way it should be done, but I have no clue on how I could possibly stabilish two connections at once.
Shouldn't this reconnection be made more safely before invoking the GetFileRequest by using the dc_id parameter of the file or something?
It indeed looks like a good possibility, because that parameter hasn't gone away and it should be possible to access it (not sure yet, can't test at the moment). But still, reconnection should be handled gracefully: disconnect, change address, and reconnect; not sure how this causes a The key is not registered in the system. error.
Isn't triggering that sudden reconnect in the middle of the execution the cause of this problem?
Again, I think it should be handled gracefully, but maybe you're right and it happens, not on the .receive() part but on the .send() one.
After some more attempts, I noticed that I received:
[09:53:34.758/MainThread] DEBUG: Handling update for object new_session_created#9ec20908 first_msg_id:long unique_id:long server_salt:long = NewSession
When trying to .receive() the InvokeWithLayerRequest (sent on reconnection) after the first error (Invalid DC). Until now, I had been ignoring these, but I decided to add another handler:
def handle_new_session_created(self, msg_id, sequence, reader):
Log.i('Handling new session created')
result = reader.tgread_object()
self.session.salt = result.server_salt
return True
Called from process_msg, if code == 0x9ec20908. However, this changed nothing. I still receive the RPCErrorof AUTH_KEY_UNREGISTERED.
Now I'm trying to connect, but for some reason, I'm getting OverflowError: can't convert negative int to unsigned when I do send the (auth.sendCode (ID: 0x86aef0ec) = (allow_flashcall=None, phone_number=+34xxxxxxxxx, current_number=None, api_id=xxxxx, api_hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)). And it's strange, because I touched nothing there.
Edit:
And it's strange, because I touched nothing there.
Nevermind, I realized I set the new .server_salt; perhaps this is the cause of it being treated as negative.
Edit 2: Yes, that was the cause, the new .server_salt was negative. But the AUTH_KEY_UNREGISTERED still happens anyway.
Is it solved?
I get
telethon.errors.rpc_error_list.AuthKeyUnregisteredError
Everytime I try to login, and after 4-5 attempts I get FloodWait Error, I am trying since last 3 days, same code works fine for other telegram account.
This error always occur on one specific account.
I also tried deleting .session file.
I am usin the latest version of telethon
Everytime I try to login, and after 4-5 attempts I get FloodWait Error, I am trying since last 3 days, same code works fine for other telegram account.
That error is per phone so deleting your session won't have any effect. Be careful about the requests you make and wait patiently.
Sorry, I pasted wrong error.
I am asking about the AuthKeyUnreisteredError
Most helpful comment
After some more attempts, I noticed that I received:
When trying to
.receive()theInvokeWithLayerRequest(sent on reconnection) after the first error (Invalid DC). Until now, I had been ignoring these, but I decided to add another handler:Called from
process_msg,if code == 0x9ec20908. However, this changed nothing. I still receive theRPCErrorofAUTH_KEY_UNREGISTERED.Now I'm trying to connect, but for some reason, I'm getting
OverflowError: can't convert negative int to unsignedwhen I do send the(auth.sendCode (ID: 0x86aef0ec) = (allow_flashcall=None, phone_number=+34xxxxxxxxx, current_number=None, api_id=xxxxx, api_hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)). And it's strange, because I touched nothing there.Edit:
Nevermind, I realized I set the new
.server_salt; perhaps this is the cause of it being treated as negative.Edit 2: Yes, that was the cause, the new
.server_saltwas negative. But theAUTH_KEY_UNREGISTEREDstill happens anyway.