Closed askucher closed 4 years ago
The same here. I think, the issue isn't in his code. The problem has been appearing for the last week or two, approximately.
I have the same problem in different projects on different hostings, which are functioning in different countries.
Waiting for the fix. Thank you.
Is there any special reason you use GetUpdates message provider instead of WebHook? GetUpdates method is issuing constant connections to Telegram servers even when there are no activity in your telegram bots/chats. Socket stays open until something happens, then messages are getting delivered and new connection is getting initiated. This works quite slow. It's not recommended for production envs and to be used during development/testing. WebHook thought works in the way, that telegram servers initiate connection to your bot when something is happening.
For webhooks a domain is needed. So it's an inefficient way to create an independent bot.
But! If something doesn't work, it doesn't mean you should change the method... So no fixes..?
Is this reproducible with latest version of library? message delivery mechanics were refactored in 2.0.
Ok, I think I reproduced this problem and just delivered the fix. Checkout version 2.0.1. Please reopen this ticket if you are able to reproduce with 2.0.1
I am sending two xlsx documents to two contacts.
// package.json
"node-telegram-bot-api": "^0.50.0",
// code
let telegramOptions = {
polling: true,
};
const telegram = new telegramBot(config.telegram.token, telegramOptions);
let ids = [111,222];
(async () => {
const document = fs.createReadStream(`./result.xlsx`);
const fileOpts = {
filename: `result.xlsx`,
contentType: `application/octet-stream`,
};
for (let i = 0; i < ids.length; i++) {
await telegram.sendDocument(ids[i], document, {}, fileOpts);
}
})();
The file comes to the first contact, and displays an error for the next contacts.
2020-12-02 23:16:49 [1606951009815] | RequestError: Error: socket hang up
at new RequestError (/root/bot/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/root/bot/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/root/bot/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/root/bot/node_modules/request/request.js:185:22)
at Request.emit (events.js:327:22)
at Request.onRequestError (/root/bot/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketOnEnd (_http_client.js:493:9)
at TLSSocket.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EFATAL'
}
When bot gets this issue it does not react on any further commands. The simple restart of process helps.
Investigation: Have checked the code and figure out that it is trying to repeat the request later but it still fails