Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewMessage event not working for majority of channels all of a sudden #682

Open
himanshuj89 opened this issue May 29, 2024 · 9 comments
Open

Comments

@himanshuj89
Copy link

Hi,

I am subscribed to 20+ Telegram channels and I was receiving all new messages until 2 days back without any issues.

Since Yesterday, I am not receiving message for NewMessage event for most of the channels. I didn't make any changes in the code.

I am only receiving this for 1-2 channels and not others. On Telegram app, I can see messages on almost all channels.

I am using below line of code for subscribing to all new messages -

client.addEventHandler(eventFunction, new NewMessage({}));

Any idea if Telegram updated something at their end?

thanks.

@boltpl81
Copy link

boltpl81 commented May 29, 2024

I thought that I messed something in the code, but it looks like it's genereral problem.
btw. it looks like a problem with channels with huge number of subscribers. Small channels are being triggered like before

@himanshuj89
Copy link
Author

Yes, correct. In my case, I am getting messages through event for channels with subscriber count around 1000 but not for channels with subscriber count more than 30000.

@boltpl81
Copy link

boltpl81 commented May 29, 2024

Couple of minutes ago I've received event from huge channel. Maybe some hickup on telegram end? I'm going to monitor the behavior.

@GuilhermeGabriel
Copy link

GuilhermeGabriel commented May 31, 2024

The same here

@justalike
Copy link

justalike commented Jun 1, 2024

can confirm, this happened to me as well.

So I've noticed that connection was established using Layer 159 which is kinda outdated?

So what I've done:
Tried to do hard reinstall of the library by

  • removing it with npm remove telegram and
  • reinstalling back with npm install telegram

Now logs say Layer 179 is used for connecting.
All of a sudden got a message from the channel with 25k+ subscribers.

Tested out (not too extensively though)

So update your lib to "telegram": "^2.21.2" to test it out.

Fixed the issue for me with no code changes.

@SwatX18
Copy link

SwatX18 commented Jun 13, 2024

can confirm, this happened to me as well.

So I've noticed that connection was established using Layer 159 which is kinda outdated?

So what I've done: Tried to do hard reinstall of the library by

  • removing it with npm remove telegram and
  • reinstalling back with npm install telegram

Now logs say Layer 179 is used for connecting. All of a sudden got a message from the channel with 25k+ subscribers.

Tested out (not too extensively though)

So update your lib to "telegram": "^2.21.2" to test it out.

Fixed the issue for me with no code changes.

Still not working for me...

@nickuya
Copy link

nickuya commented Jun 15, 2024

I was running into the same issue. When I started up my program, I would receive new messages for my large channels but after about 2 minutes it would stop.

One day I left the program running anyways, and then after about 10-20 minutes I noticed a timeout error in my logs and started receiving new messages again. I tracked down the timeout to here

} catch (err) {
// eslint-disable-next-line no-console
if (client._errorHandler) {
await client._errorHandler(err as Error);
}
if (client._log.canSend(LogLevel.ERROR)) {
console.error(err);
}
lastPongAt = undefined;
if (client._sender!.isReconnecting || client._isSwitchingDc) {
continue;
}
client._sender!.reconnect();
}

so something in there seemed to kickstart the ability to receive messages again.

using that, I implemented an interval to just call the same reconnect method as at the bottom of that error handler.

setInterval(async () => {
  client._sender?.reconnect();
}, 1000 * 60);

bit of a hack. seems like it's possible to end up missing messages, but for my purposes seems to work so far.

Hope it works for others.

@sbeben
Copy link

sbeben commented Nov 26, 2024

same here
also, the workaround proposed by @nickuya does not work as reconnects are never successful for some reason
version 2.26.7
layer 193

@MishaMgla
Copy link

Experiencing same issue. With some messages it works flawlessly, with some NewMessage event is never triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants