telegram-bot-api icon indicating copy to clipboard operation
telegram-bot-api copied to clipboard

[Bug] Cannot upload file in local mode due to idleTimeout

Open NyaMisty opened this issue 4 years ago • 5 comments

I'm using telegram-bot-api in local mode so that I can directly let it uploading file from disk by passing file:// url to send_document.

However, when the bandwidth is limited, upload can take a long time like 30 minutes, and that means 30 minutes' idle time waiting for file upload on that connection.

But the idleTimeout is only 500 seconds. That makes the file upload request of big file are never responded, whereas file are still being uploaded.

NyaMisty avatar Jan 10 '22 18:01 NyaMisty

The file will be sent anyway, just the answer will not be sent. But if a request needs more than 8 minutes to complete, then the bot is barely usable. And everything will be much worse, if the bot would be used by more than one user. So, increasing the limit makes no sense generally, but if you really need a bigger limit, you can change it in https://github.com/tdlib/telegram-bot-api/blob/93ccd2a145926612dc45c5e095560e43fbd94d2a/telegram-bot-api/HttpServer.h#L69.

levlam avatar Jan 11 '22 10:01 levlam

Thanks for your reply. Actually I've changed that timeout to 0 to totally disable it, and the bot works still fine as it's a local server.

But there're a few point I can't agree with you:

  1. Bot can be not fully interactive. For example, bot can download & upload files in the background, then send the files to users with file_id. My software upgrade monitor works exactly this way

  2. Changing source code is easy, but recompiling is not. telegram-bot-api has some prebuilt docker containers, if I patch the source code, I would have to rebuild it, which is a pretty time-consuming task considered that tdlib is a pretty large library.

I believe that the idleTimeout should be documented and configurable.

NyaMisty avatar Jan 11 '22 10:01 NyaMisty

@levlam I'm running into the similar problem as well. When multiple clients request to download a file from Telegram, it takes more than 10 minutes to do so. Then requests are timed-out with EOF error.

I believe an argument for setting the time-out when starting the server is essential.

The solution I'm trying to use now is to constantly check for download folder to see if new files are added. But that's a terrible solution.

aliforever avatar Mar 11 '22 09:03 aliforever

You can view the my fork project, it support use http proxy and setup idle-timeout parameters.

ZhangYiQiu/telegram-bot-api

add http proxy parameters

--enable-http-proxy             Enable HTTP proxy
--http-proxy-ip=<arg>           HTTP proxy ip (default is 127.0.0.1)
--http-proxy-port=<arg>         HTTP proxy port (default is 4780)

add idle timeout parameters

--idle-timeout=<arg>             idle timeout (default is 500)

ZhangYiQiu avatar Jan 11 '24 05:01 ZhangYiQiu