tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
3.09k stars 590 forks source link

Low speeds on local server #546

Closed kupeepla closed 2 months ago

kupeepla commented 6 months ago

Hello,

I having problem regarding the speed of responses to commands and other requests earlier my bot was on api.telegram.org but later i planned to move bot to local server because sometimes i might need to send files over 50MB

but i noticed that even 5-10MB file takes 60-70 seconds sometimes 2-3 mins to deliver/uploaded and user gets it.

Before you guys ask for the log file please let me know where do i find the log file.

Thank you

levlam commented 6 months ago

Do you have a high-speed internet connection on the server where the Bot API server is hosted?

You can enable logs by adding parameters -v4 -l log.txt to the Bot API server and send the file log.txt to https://t.me/tdlib_bot to know the exact reason.

kupeepla commented 6 months ago

Yes its 1gbps unshared. ( dedicated server ) btw, my bot is a kind of downloader where user sends the instagram post link ( image / video ) and they get the media file. on api.telegram.org it happens in a blink of an eye but on locally it takes 1-2 mins

specially video when i try to send the video i get this error

An error occurred while sending video to user : invalid json response body at http://<DOMAIN.com?/bot/sendVideo reason: Unexpected token < in JSON at position 0

also should i user IP:PORT or domain.com and with http or https ?

levlam commented 6 months ago

Why do use domain at all and don't host the Bot API server on the same server as the bot?

kupeepla commented 6 months ago

Bot and BOT API both are hosted on same server, i think because i am using HTTP://ip:port and not HTTPS my download/upload speed is capped to certain kbps maybe

And i thought if i use HTTPS with domain name i will get good speeds

What to do ?

P.S. https://t.me/tdlib_bot not responding

levlam commented 6 months ago

Bot and BOT API both are hosted on same server,

Then you should send request to http://127.0.0.1:. You should also consider to send local files using file:// URI scheme as specified in https://github.com/tdlib/telegram-bot-api?tab=readme-ov-file#usage.

kupeepla commented 6 months ago

Files are not on the disk i am sending media link directly to user using replywithVideo / replywithphoto with url, My bot really works fast on api.telegram.org and i am using same sending methods and i do succeed its just that its super slow on BOT API

botlogs.txt

These are my logs,

levlam commented 6 months ago

In the log upload speed is less than 1 megabit per second. The speed depends on your server and there is no way to upload files with a higher speed.

kupeepla commented 6 months ago
image

This is my speed tests, also download and uploading speed on other apps are very impressive

kupeepla commented 6 months ago

thats the sample code

const { Telegraf } = require('telegraf');

const bot = new Telegraf('', { telegram: { apiRoot: 'http://IP:PORT' }, });

bot.start((ctx) => ctx.reply('Welcome! Use /send to get a video.'));

bot.command('send', (ctx) => { const videoUrl = ''; ctx.replyWithVideo(videoUrl); });

bot.launch();

BigBroFinch commented 4 months ago

thats the sample code

const { Telegraf } = require('telegraf');

const bot = new Telegraf('', { telegram: { apiRoot: 'http://IP:PORT' }, });

bot.start((ctx) => ctx.reply('Welcome! Use /send to get a video.'));

bot.command('send', (ctx) => { const videoUrl = ''; ctx.replyWithVideo(videoUrl); });

bot.launch();

I also have the ### same problem, is there an answer now?