-
Notifications
You must be signed in to change notification settings - Fork 178
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 stops triggering from channels after ~10 seconds since connection #654
Comments
I got the same issue |
I wonder if it's telegram restricting the account because I have another account that works just fine with the same code. However when I check with the spam bot, it tells me that there are no restrictions applied to my account. |
Whenever I use the setDC it either freezes my current session or when I use it for a new session I get "Phone Migrated to DC 4" |
@Metalingus |
For now I implemented an ugly solution. I created 3 sessions that disconnect reconnect every 5 seconds. As mentioned earlier, this is related to DC4, I created a new account there and the same thing happened. I also tried telethon and it's happening too unless I keep interacting with the channel. |
It happened with me in 2022 and the solution was to update the gramjs library. This time it didn't fix it. I am also having the same issue. |
Hi guys, so this is an official telegram api issue? This issue is seriously hampering my development of telegram-forwarder, the listen function is very important to me, but so far the test result is that after 2 minutes I don't receive any new messages anymore! |
I am also having the same issues with my telegram-forwarder. Did you find any solution yet? |
Same issue for me in DC4. Change DC doesn't help: I've created a new account in DC5 but it has the same issue. |
I fixed it by calling getDialogs on an interval of 30 seconds. It has been more than 24 hours already and it seems to be working fine for me. |
@mominak47 Hi, Have you tested any methods other than getDialogs()? Like getMe() method or something like that. It seems that you have to call a specific method periodically during the listening process to maintain contact, am I correct in my understanding? Thank you for your reply. |
@mominak47 Which version of the package are you running? |
@awdr74100 Yeah, you have to call getMe() once after client.connect() . I was using the same way for more than an year and somehow it recently stopped working. I managed to run it again after calling getDialogs on every 30 seconds. |
@mominak47 Thank you for your immediate reply! I'm still not sure if this is some kind of official limitation of the telegram api, where monitoring can be kept running 24 hours a day with infrequent channel updates, whereas with frequent channel updates, monitoring can only be kept running for 2 minutes, and then no more updates can be received, which means that the callback of the addEventHandler will never be invoked. I've tried gramjs, tgsnake, mtkruto and all have the same problem. I suspect the problem may be related to calls like |
I experience the same: NewMessage event is not triggered, BUT only for some "specific" groups. I don't know yet what makes those groups different. Appearantly even official app is working like that: I receive push notifications, but I can not see any chat updates on listing until I actually visit that channel/group (which makes me believe instead of NewMessage event triggered it's just |
сообщения из reciver иногда приходят, иногда не приходят. |
What version are you using? |
recent (2.20.10) even though when you start the app it shows |
Versions: Curious if this issue would occur in a telegram python package, though i wouldn't want to switch from nodejs... async function listenToNewMessage(event: NewMessageEvent) {
const message = event.message;
if (
message.isChannel &&
(Number(message.chatId) == channels_id.CHANNEL_I_WANT_TO_LISTEN_TO ||
Number(message.chatId) == channels_id.CHANNEL_I_WANT_TO_LISTEN_TO_2 ||
Number(message.chatId) == channels_id.MY_TESTING_CHANNEL)
) {
try {
const translated = await gpt_translate(message.message);
console.log("Translated message: ", translated);
message.message = translated;
await client.sendMessage(channel_name, {
message: message.message,
});
} catch (e) {
console.log(e);
}
}
}
// ...
client.addEventHandler(listenToNewMessage, new NewMessage({})); My listener does work when the channel is Something i did pay attention is that on my local environment the eventHandler does work for the three channels, but when it's on my deployed EC2 server it never does. NOTE: |
After downgrading to 19.0.0, it still doesn't work on production, and work time to times in local, but most of the time it doesn't work
|
I have the same problem. Has anyone found a solution? |
Anyone found any solution for this? I am also stuck on same. |
Проблема в том что не может одновременно работать отправка и прием сообщений в одном питоновском скрипте. Я сделал два питоновских скрипта в разных окружениях, на прием и на отправку. И все работает. |
I solved it by using another telegram account. Its not working in the same account. |
Работает. Нужно лишь второе окружение. |
Everything was working fine until today, NewMessage event stops firing from channels after around 10 seconds from starting the program. I am still getting NewMessage event from private chats. I tried periodically calling .getMe() but it didn't help.
The text was updated successfully, but these errors were encountered: