gramjs
gramjs copied to clipboard
TIMEOUT I'm using version 2.6.13
Version 2.6.13 the same problem occurs, A large number of timeouts will occur in the program running for a long time, which will eventually lead to 100% of the CPU and the server cannot be used.

cpu-profile-6942-20220420-174229.cpuprofile.zip This is the result of node.js cpu analysis
is that the only code you're using? can you send a small reproducible code ?
is that the only code you're using? can you send a small reproducible code ?
Sorry, I can't reproduce this problem locally, but I can provide a development environment server, you can connect to the development environment server to view this error
is that the only code you're using? can you send a small reproducible code ?
This problem has been bothering me for a long time, I hope you can provide telegram contact information, I will send you the ip of the development environment server, you can connect to the server to see the log
is that the only code you're using? can you send a small reproducible code ?
timeout is not a network connection timeout, Some connections will have a timeout, but there is no problem with the network
Error: Cannot send requests while disconnected. You need to call .connect()
at MTProtoSender.send (/root/telegram-transport/node_modules/telegram/network/MTProtoSender.js:197:19)
at /root/telegram-transport/node_modules/telegram/client/updates.js:163:47
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:26)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
Error: TIMEOUT
at /root/telegram-transport/node_modules/telegram/client/updates.js:218:55
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:20)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
Error: TIMEOUT
at /root/telegram-transport/node_modules/telegram/client/updates.js:218:55
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:20)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
Error: Cannot send requests while disconnected. You need to call .connect()
at MTProtoSender.send (/root/telegram-transport/node_modules/telegram/network/MTProtoSender.js:197:19)
at /root/telegram-transport/node_modules/telegram/client/updates.js:163:47
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:26)
at runMicrotasks (<anonymous>)
at runNextTicks (internal/process/task_queues.js:60:5)
at listOnTimeout (internal/timers.js:526:9)
at processTimers (internal/timers.js:500:7)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
Error: TIMEOUT
at /root/telegram-transport/node_modules/telegram/client/updates.js:218:55
at runMicrotasks (<anonymous>)
at runNextTicks (internal/process/task_queues.js:60:5)
at listOnTimeout (internal/timers.js:526:9)
at processTimers (internal/timers.js:500:7)
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:20)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
Error: Cannot send requests while disconnected. You need to call .connect()
at MTProtoSender.send (/root/telegram-transport/node_modules/telegram/network/MTProtoSender.js:197:19)
at /root/telegram-transport/node_modules/telegram/client/updates.js:163:47
at attempts (/root/telegram-transport/node_modules/telegram/client/updates.js:203:26)
at Object._updateLoop (/root/telegram-transport/node_modules/telegram/client/updates.js:162:13)
https://github.com/gram-js/gramjs/blob/b6b46c8699d7ce5e2290cabf0a5cdc0578dbecc8/gramjs/client/updates.ts#L258
You can find me in https://t.me/gramjschat
There are updates on this topic?
There are updates on this topic?
The latest version should have had some fixes for this.
Hi guys. I'm using version 2.17.4 and still getting timout on error log.
Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17) Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17) Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17) Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17) Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:540:9) at processTimers (node:internal/timers:514:7) at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17) Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85 at attempts (/home/user/node_modules/telegram/client/updates.js:228:20) at _updateLoop (/home/user/node_modules/telegram/client/updates.js:180:17)
my code:
async main(): Promise<void>
{
const sessionTxt: string = fs.readFileSync(__dirname + '/data/session.txt', {encoding: 'utf-8'}),
stringSession: StringSession = new StringSession(sessionTxt),
client: TelegramClient = new TelegramClient(stringSession, *, '*', {connectionRetries: 10});
client.setLogLevel(LogLevel.ERROR);
await client.start(
{
phoneNumber: '*',
phoneCode: async () => await input.text('Code:'),
onError: (err) => console.error(err)
});
fs.writeFileSync(__dirname + '/data/session.txt', (<StringSession> client.session).save(), {encoding: 'utf-8', flag: 'w'});
do
{
client.connect();
await sleep(2000);
if(!client.connected) fs.writeFileSync(__dirname + '/logs/connect_log', new Date() + ' Not connected' + '<br>\n<br>\n', {encoding: 'utf-8', flag: 'a'});
}
while(!client.connected);
let lastMessages: Api.TypeMessage[], lastMessage: Api.Message;
lastMessages = (<Api.messages.Messages> await client.invoke(new Api.messages.GetHistory(
{
peer: <bigInt.BigInteger> (<unknown> -1001717037581),
limit: 20
}))).messages;
lastMessages.forEach((msg: Api.Message) =>
{
if(msg.replyTo === null)
if(msg.message && msg.message.startsWith('🔥'))
{
if((Date.now() - msg.date*1000) < 120000)
{
const lines: string[] = msg.message.split('\n\n'),
config: any = JSON.parse(fs.readFileSync(__dirname + '/data/config.json', {encoding: 'utf-8'})),
excluded: boolean = config.excluded;
if(!excluded) this.doSomething();
fs.writeFileSync(__dirname + '/logs/telegram_log', new Date() + `\n ${msg.message} \n\n`, {encoding: 'utf-8', flag: 'a'});
}
}
});
client.disconnect();
}
this code is executed every minute by a cronjob.
my code:
async main(): Promise<void> { const sessionTxt: string = fs.readFileSync(__dirname + '/data/session.txt', {encoding: 'utf-8'}), stringSession: StringSession = new StringSession(sessionTxt), client: TelegramClient = new TelegramClient(stringSession, *, '*', {connectionRetries: 10}); client.setLogLevel(LogLevel.ERROR); await client.start( { phoneNumber: '*', phoneCode: async () => await input.text('Code:'), onError: (err) => console.error(err) }); fs.writeFileSync(__dirname + '/data/session.txt', (<StringSession> client.session).save(), {encoding: 'utf-8', flag: 'w'}); do { client.connect(); await sleep(2000); if(!client.connected) fs.writeFileSync(__dirname + '/logs/connect_log', new Date() + ' Not connected' + '<br>\n<br>\n', {encoding: 'utf-8', flag: 'a'}); } while(!client.connected); let lastMessages: Api.TypeMessage[], lastMessage: Api.Message; lastMessages = (<Api.messages.Messages> await client.invoke(new Api.messages.GetHistory( { peer: <bigInt.BigInteger> (<unknown> -1001717037581), limit: 20 }))).messages; lastMessages.forEach((msg: Api.Message) => { if(msg.replyTo === null) if(msg.message && msg.message.startsWith('🔥')) { if((Date.now() - msg.date*1000) < 120000) { const lines: string[] = msg.message.split('\n\n'), config: any = JSON.parse(fs.readFileSync(__dirname + '/data/config.json', {encoding: 'utf-8'})), excluded: boolean = config.excluded; if(!excluded) this.doSomething(); fs.writeFileSync(__dirname + '/logs/telegram_log', new Date() + `\n ${msg.message} \n\n`, {encoding: 'utf-8', flag: 'a'}); } } }); client.disconnect(); }
this code is executed every minute by a cronjob.
I'd have the same problem, I think this is a Gram js bug, and I hope that will be fixed in the next version
for this error (Error: TIMEOUT at /home/user/node_modules/telegram/client/updates.js:244:85)
go to this file (updates.js) line 244 and remove await before the promise. enjoy!
go to this file (updates.js) line 244 and remove await before the promise. enjoy!
I don't think is good for production this...
I've upgraded to 2.19.10 and I'm now facing this, I don't think I had the issue in 2.17.4