question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot send requests while disconnected. You need to call .connect()

See original GitHub issue

My app work fine, but sometimes it fall down with error:

Error: Cannot send requests while disconnected. You need to call .connect(), which begin run in endless cycle

then script die with another error:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

so my question is:

what is the bug with this:

Error: Cannot send requests while disconnected. You need to call .connect() ?

Why this sometimes run in endless cycle and never end? This definitely need to be fixed.

This bug was in version 2.5.* and now in 2.6.13 it has too.

Full error look like this:

Error: Cannot send requests while disconnected. You need to call .connect()
    at MTProtoSender.send (/code/node_modules/telegram/network/MTProtoSender.js:197:19)
    at Object.invoke (/code/node_modules/telegram/client/users.js:31:36)
    at async TelegramClient.getDC (/code/node_modules/telegram/client/TelegramClient.js:1120:28)
    at async TelegramClient._connectSender (/code/node_modules/telegram/client/telegramBaseClient.js:200:20)
    at async TelegramClient._borrowExportedSender (/code/node_modules/telegram/client/telegramBaseClient.js:243:22)

p.s.: right before this error it show this:

Error: Disconnect 
 at /code/node_modules/telegram/extensions/MessagePacker.js:106:33 
 at Array.forEach (<anonymous>) 
 at MessagePacker.rejectAll (/code/node_modules/telegram/extensions/MessagePacker.js:105:29) 
 at MTProtoSender._disconnect (/code/node_modules/telegram/network/MTProtoSender.js:247:25) 
 at MTProtoSender.disconnect (/code/node_modules/telegram/network/MTProtoSender.js:168:20) 
 at MTProtoSender._reconnect (/code/node_modules/telegram/network/MTProtoSender.js:728:24) 
 at /code/node_modules/telegram/network/MTProtoSender.js:721:22

Thanks.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
icanarycommented, May 18, 2022

If there is an error during the authentication process there is an “onError” callback that you can use to either continue the authentication process or to exit.

this may happen during client.connect(), but not during authentication process. So this is another situation here.

0reactions
vitalystercommented, May 20, 2022

FLOOD_WAIT issue is just a case when “Error: Cannot send requests while disconnected” and crash happens

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot send requests while disconnected" error when ...
I try to write code to download all messages and media from specific channel. Getting messages without downloading media works fine.
Read more >
flask - Connection error while connection has already been ...
') The following error occurs despite the fact that I have already established a connection: ConnectionError: Cannot send requests while ...
Read more >
"Cannot send requests while disconnected" error when ...
I try to write code to download all messages and media from specific channel. Getting messages without downloading media works fine.
Read more >
Client API
An "error" event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent.
Read more >
Why do I get a connection error when installing or ...
I get an error that I cannot connect to MathWorks when running the MathWorks installer or the activation client; however, I can access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found