-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Exception: Number of retries reached 0. #270
Comments
If any request has a Telethon/telethon/telegram_bare_client.py Line 345 in 3fda7ef
It's going to retry: Telethon/telethon/telegram_bare_client.py Lines 348 to 350 in 3fda7ef
Up to five times before raising an error: Telethon/telethon/telegram_bare_client.py Lines 307 to 308 in 3fda7ef
I don't know why the result of some requests |
Maybe the exception on |
Yes, the exception there is this one, because logging out is "confirmed" through a message acknowledge and no result is actually read. From my experience, I think ack requests are only used int this case… So no result per se is set. Is using |
Seems to work with |
In log I see the problem only with |
The error may be because |
I have the same exception. telethon 0.15.0.3 |
ReadHistoryRequest |
So are you saying that with |
exception occurs when there are no unread messages |
If anyone wants to test, doing this would be really helpful. The only requirement is that you can reproduce this bug. Add this class to from threading import Event
import traceback
import os
class LoggingEvent:
def __init__(self, t):
self.o = open(os.path.expanduser('~/telethon.log'), 'w')
self.e = Event()
self.t = type(t).__name__
def _log(self, k):
m = '-- '+k+' FLAG ON '+self.t.+' --'
self.o.write(m+'\n')
traceback.print_stack(file=self.o)
self.o.write('-'*len(m)+'\n\n\n')
self.o.flush()
def clear(self):
self._log('CLEARING')
return self.e.clear()
def set(self):
self._log('SETTING')
return self.e.set()
def is_set(self):
return self.e.is_set()
def wait(self, *a, **k):
self.e.wait(*a, **k) Then, inside the self.confirm_received = Event() with self.confirm_received = LoggingEvent(self) |
how can I check the number of unread messages? |
|
This is false-y, so it's probably the reason why the exception occured. Can you test again? It likely was fixed on 244a47c. |
I has stuck on this Exception too. Currently I skip these requests: def my_method(self):
try:
dialogs, entities = self._client.get_dialogs()
except Exception as e:
time.sleep(1) # I hope what after delay connection will be repaired
raise MyApiException('Im sorry, try later')
return dialogs
def call_my_method(self):
try:
dialogs = self.my_method()
except MyApiException as e:
self._log(str(e))
return
self.process_dialogs(dialogs) |
I've reproduced the bug successfully. Here's the log:
|
With the latest commits from master, I now get |
No, there's a threshold (defaults to 30 seconds). If it's longer than that you don't want the library to just hang, you may want to take other actions. You should be able to modify that threshold to be as big as you need. |
Oh, I see. How do you set it up? I don't see any relevant parameters on |
Was mistaken, one minute actually. It's here. |
@pashbelg are you willing to help or were you just confirming you have this issue too? If the latter, that's not too helpful. |
If I use 'InteractiveTelegramClient' instead of 'TelegramClient' .connect() ,it is not throwing this exception |
I also get this exception randomly after doing some GetDialogsRequest. But after some pause invoking same request doesn't raise error even if dialogs did not change at all. |
I've fixed many aspects of this issue and the last one I've found for today. I've found that sometimes Telegram stops send any responses. |
Is it possible to quickly check whether the socket has been closed, so we can do it when retrying? Shouldn't it error with "socket closed" while trying to read already? The background thread should be reconnecting. Maybe retries happen too quick? |
No, the socket is not closed because of |
Is the |
I don't use the master version last time. I gave you a hint, you can investigate more by yourself. According the source code it can't be raised immediately, just after retries exceeded. Yes, it waits for timeout and timeout is happened. |
Okey. I've managed to find something about this. I had one session file and I made two copies of it. However, I started the same script in parallel with the SECOND fresh copy of the session and it started working like if nothing happened, while first was struggling to do anything. Then I replaced first copy with the second one and it also started working. So I can assume that the cause may lie within the session file and not because of connection problems or Telegram server rejecting requests. Maybe, data, i.e. auth_key or salt, somehow becomes damaged and inflicts bad responses from servers. Unfortunately, I forgot to make a backup of "bad" copy to check if there were differences. That's all I know at the moment. I'm trying to find the way to reproduce this, to investigate it more. |
Bump. Does this still happen as of |
@Lonami yes , I have tried to forward a message in 2 megagroups and after about 20 times of forwarding, with 5min sleep between each time, I got this error. |
how can I create client using Telethon because when I am executing this code it says from telethon import TelegramClient api_id = 00000 client = TelegramClient('session_name', api_id, api_hash) ERROR: Traceback (most recent call last): |
@Lonami Can't write it's showing " This conversation has been locked as resolved and limited to collaborators. " |
@rex101 stop commenting on completely unrelated issues. |
Hi guys I get This Number of Retries reached 0 message for GetHistoryRequest when i try to fetch channel posts. is this related to this issue or not? thanks |
Same for me, but still looking for a pattern to reproduce. Will update here whenever I find something useful. However, and I don't know if it's useful or have something to do with this, when this exception is raised and I retry the exact same query, another exception with the message "Telegram's having problems right now, try again later" is raised. I use "limit=None" as others |
Yesterday I was having some trouble to iterate over all messages of a channel too, I got a few "internal errors from Telegram", but not "retries reached 0" |
I have a python script running in a loop, checking new messages every 5 minutes. After a while, the error appears: 2018-04-18 06:46:45 If I kill the running script and start again, it's fine for hours. Then the error comes back. What can I do to help to resolve this? |
You can create a Minimal Working Example for me to try and reproduce the issue, with the hope that I can fix it. Otherwise enable |
Has the issue fixed? Or anyone has found an alternative method? I get these Number of retries reached 0 errors very frequently. |
Some new shiny logs:
Seems that the problem is located here:
|
bb3a564 has been merged, reopen after the next version is published if this error still occurs. Note that |
Still happens. |
Really? |
@Lonami - apparently, Telegram servers were down for about an hour. |
I did notice that. So not an issue. |
Not an issue in Telethon, that's for sure. |
Hi.
Is this because of my old version of telethon? |
Quite possibly. Old versions are not supported at all. |
The same too.
|
It's impossible 1.4.1 shows "the same" because that error is gone. Please show a DEBUG log with 1.4.1 if it really happens "the same". |
I haven't check on new version v0.14, but previous one this exception happened very often on outgoing requests in a random time. I don't know: Telegram servers sometime is slow or it's flood protection. Definitely this exception has to be more informative to understand the reason of it.
The text was updated successfully, but these errors were encountered: