yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.13k stars 1.49k forks source link

Polling Errors: constantly returning 302 redirects #1098

Open markschellhas opened 1 year ago

markschellhas commented 1 year ago

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

Being able to receive messages/updates from Telegram bot.

Actual Behavior

Constant 302 redirect errors:

console extract:

error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}
error: [polling_error] {"code":"EPARSE","message":"EPARSE: Error parsing response: <html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.18.0</center>\r\n</body>\r\n</html>\r\n"}

Steps to reproduce the Behavior

Using node version 20.2.0, running this code produces the error:

const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot(token, {polling: true});

bot.on('message', (msg:any) => {
    const chatId = msg.chat.id;
    console.log(msg);
    bot.sendMessage(chatId, 'Received your message');
});

I have checked that the token and chatId is indeed correct. I am able to make post requests successfully using fetch, only getting errors when using this library.

Any insight would be greatly appreciated!

un-versed commented 10 months ago

Having the same issue here, any update on this @markschellhas ?

beshur commented 9 months ago

Same for me