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

Fix timeouts when sending large files #533

Closed
5 of 7 tasks
tsnoam opened this issue Feb 27, 2017 · 14 comments
Closed
5 of 7 tasks

Fix timeouts when sending large files #533

tsnoam opened this issue Feb 27, 2017 · 14 comments
Assignees
Labels
Milestone

Comments

@tsnoam
Copy link
Member

tsnoam commented Feb 27, 2017

This issue is in order to track the various tasks of a bug in master branch.
The problem is that urllib3 doesn't honour the read_timeout when using a newly created connection. However, with an existing connection it works just fine.
Regardless of working with upstream urllib3 to fix the issue, we need to fix the issue for v6.0 milestone.

  • Create a unitest to recreate the problem. See in travis that the problem is recreated.
  • "Vendor" a fork of urllib3 with a fix with python-telegram-bot package.
  • Check that the unitest is now fixed.
  • Modify defaults of timeouts to sane values:
    • connect_timeout = 5 seconds
    • read_timeout = 5 seconds
    • sendDocument, sendAudio & similar methods = 20 seconds.
@tsnoam tsnoam added this to the 6.0 milestone Feb 27, 2017
@tsnoam tsnoam self-assigned this Feb 27, 2017
@Eldinnie
Copy link
Member

Eldinnie commented Mar 7, 2017

Is it possible this has to do with this? https://core.telegram.org/api/optimisation#downloading-files-and-uploading-data-to-the-server It mentions:

It makes sense to download files over several connections (optimally to have a pool). When uploading data to a server one connection is enough to achieve the best results.

I'm not really into this connectionstuff myself, but as far as I read the code, sending of files goes via the same connection_pool as all other tasks. It seems TG is advising against this.

@tsnoam
Copy link
Member Author

tsnoam commented Apr 29, 2017

Unitesting is tricky as this one is hard to recreate.
We're going to release v6 with our vendored urllib3 version and see how to go forward from there.
Keeping this issue open for reference,

@tsnoam tsnoam mentioned this issue Apr 29, 2017
@Eldinnie
Copy link
Member

@tsnoam do we still need this issue open? Or can we safely say this issue has been resolved?

@tsnoam
Copy link
Member Author

tsnoam commented Sep 11, 2017

@Eldinnie i am not yet convinced that the problem is fully fixed and/or that we don't left overs. I do know that the situation is much better than the past (or people stopped complaining...).
There are a few reports of timeouts issue which require more thorough investigation.
please keep this open.

@Eldinnie
Copy link
Member

@tsnoam 👍

@EnricoVerzegnassi
Copy link

EnricoVerzegnassi commented Sep 15, 2017

I have this problem too on my raspberry with ArchLinux Arm.
When I send files bigger than ~5 Mb, python stops uploading, therefore I do not receive the file in the telegram chat.

@tsnoam
Copy link
Member Author

tsnoam commented Sep 15, 2017

@ilverz It doesn't necessarily be the same issue. Have you tried increasing the timeout?

@EnricoVerzegnassi
Copy link

@tsnoam Actually no, I'm sorry, but how can I set the timeout?
I just use the "bot" object from which I call the method "send_document".

@Eldinnie
Copy link
Member

@EnricoVerzegnassi
Copy link

@Eldinnie Solved! Thank you guys, and sorry for the stupid error.

@5p4k
Copy link

5p4k commented Sep 19, 2017

Hello, I am seeing a massive amount of timeout when sending photos or videos (fails in almost all cases). I see data being transferred, but if it doesn't get transferred within the amount of time specified in the timeout, it will fail nonetheless with a timeout error. To send some 500KB of photo, I had to set manually the timeout parameter to 20 (I know it was supposed to be default, but unless I do that, it fails).

Shouldn't the timeout trigger when the specified amount of time elapses without any data being transferred? It seems that timeout refers, in behaviour, to the maximum amount of time by which the transfer has to be completed. This doesn't make sense to me, as it would imply that the timeout scales up with the size of the media being transferred.

I could not understand exactly the gist of this issue from the description, but it seems very closely related – if that's not the case, I'd be happy to open a new issue.

@5p4k
Copy link

5p4k commented Sep 20, 2017

Hello, I am seeing massive timeouts when sending photos and videos above 1MB. I did not understand the gist of this issue from the description, but it seems related (if not, I'd be happy to open a new one). I have noticed two things

  1. Although the default timeout is said to be 20 seconds, I actually had to specify it explicitly in send_video and send_photo for it to be taken in effect (otherwise it would time out in ~5 secs)
  2. The timeout parameter, seem to refer to the overall time the transfer takes. Shouldn't it be the maximum time that is allowed to elapse without transferring any data?

More on 2.: I see data being transferred and maybe a few seconds more would have allowed the file to go through. Also, with the current behaviour, the timeout should be scaled up with the file size, and this does not make sense to me.

@tsnoam
Copy link
Member Author

tsnoam commented Oct 11, 2017

We've done what we can to fix the issue and it seems like it was (or at least significantly improved to the state that the community is happy).
Unfortunately we don't see how to implement unitests to recreate the timeout issue - we just fail to recreate this in "lab".

I'm closing this issue to remove "noise" from the issue lists.

@tsnoam
Copy link
Member Author

tsnoam commented Oct 11, 2017

@LizardM4
If you're not there already, you're welcome to join our community ask usage questions there. If eventually you find a bug with the library please open a new issue in github.

@tsnoam tsnoam closed this as completed Oct 11, 2017
@python-telegram-bot python-telegram-bot locked and limited conversation to collaborators Oct 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants