gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

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

Open himanshuj89 opened this issue 1 year ago • 13 comments

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.

himanshuj89 avatar May 29 '24 07:05 himanshuj89

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

boltpl81 avatar May 29 '24 09:05 boltpl81

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.

himanshuj89 avatar May 29 '24 10:05 himanshuj89

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

boltpl81 avatar May 29 '24 10:05 boltpl81

The same here

GuilhermeGabriel avatar May 31 '24 17:05 GuilhermeGabriel

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.

justalike avatar Jun 01 '24 12:06 justalike

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...

SwatX18 avatar Jun 13 '24 13:06 SwatX18

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 https://github.com/gram-js/gramjs/blob/5a0f45b2b5f30472634d9948cbc404b09b54e0c7/gramjs/client/updates.ts#L245-L260

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.

nickuya avatar Jun 15 '24 14:06 nickuya

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

sbeben avatar Nov 26 '24 16:11 sbeben

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

MishaMgla avatar Jan 22 '25 12:01 MishaMgla

I'v been experiencing this same issue the last two days, did anyone managed to fix it ?

egarciahz avatar May 22 '25 05:05 egarciahz

Any update on this? facing same, suddenly stopped receiving events

thegauravparmar avatar Jul 11 '25 20:07 thegauravparmar

Same

indapublic avatar Aug 24 '25 00:08 indapublic

bump, same here

firdiar avatar Nov 01 '25 10:11 firdiar