Code Monkey home page Code Monkey logo

Comments (21)

Metalingus avatar Metalingus commented on July 28, 2024 2

@Metalingus Do you have any idea to workaround for this case ?

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.

from gramjs.

hoanglm4 avatar hoanglm4 commented on July 28, 2024

I got the same issue

from gramjs.

Metalingus avatar Metalingus commented on July 28, 2024

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.

from gramjs.

Metalingus avatar Metalingus commented on July 28, 2024

Try to change DC: client.session.setDC(dcId: number, serverAddress: string, port: number); https://docs.pyrogram.org/faq/what-are-the-ip-addresses-of-telegram-data-centers I have a problem with DC4

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"

from gramjs.

hoanglm4 avatar hoanglm4 commented on July 28, 2024

@Metalingus
Do you have any idea to workaround for this case ?

from gramjs.

mominak47 avatar mominak47 commented on July 28, 2024

@Metalingus Do you have any idea to workaround for this case ?

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.

from gramjs.

awdr74100 avatar awdr74100 commented on July 28, 2024

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!

from gramjs.

mominak47 avatar mominak47 commented on July 28, 2024

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?

from gramjs.

jekatigr avatar jekatigr commented on July 28, 2024

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.

from gramjs.

mominak47 avatar mominak47 commented on July 28, 2024

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

from gramjs.

awdr74100 avatar awdr74100 commented on July 28, 2024

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

from gramjs.

TwizzX17 avatar TwizzX17 commented on July 28, 2024

@mominak47 Which version of the package are you running?

from gramjs.

mominak47 avatar mominak47 commented on July 28, 2024

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

from gramjs.

awdr74100 avatar awdr74100 commented on July 28, 2024

@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 UpdatesTooLong getDifference.

from gramjs.

maciejkwas avatar maciejkwas commented on July 28, 2024

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 getDifference that makes recent messages visible there).

from gramjs.

peacedoorballl avatar peacedoorballl commented on July 28, 2024

сообщения из reciver иногда приходят, иногда не приходят.
использую node-red-node-telegrambot 0.1.6
https://flows.nodered.org/node/node-red-node-telegrambot

from gramjs.

mominak47 avatar mominak47 commented on July 28, 2024

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 getDifference that makes recent messages visible there).

What version are you using?

from gramjs.

maciejkwas avatar maciejkwas commented on July 28, 2024

What version are you using?

recent (2.20.10) even though when you start the app it shows Running GramJS version 2.20.9 in logs. I downgraded back to 2.17.10 and had the same.

from gramjs.

ioeldev avatar ioeldev commented on July 28, 2024

Versions:
"telegram": "^2.20.10"

Curious if this issue would occur in a telegram python package, though i wouldn't want to switch from nodejs...
This also occurs for me.

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 channels_id.MY_TESTING_CHANNEL, but for the two others it doesn't even get called, like something is blocking the eventHandler when it's some specific channels, even though the config seems to be the same on the three channels (it is a public channel; I have joined the three channels).

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:
I just saw that my local node version is v19.0.0 whereas my EC2 has 21.7.0 installed.
Checking now if downgrading to 19 will make a change, will update here :)

from gramjs.

ioeldev avatar ioeldev commented on July 28, 2024

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

Versions: "telegram": "^2.20.10"

Curious if this issue would occur in a telegram python package, though i wouldn't want to switch from nodejs... This also occurs for me.

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 channels_id.MY_TESTING_CHANNEL, but for the two others it doesn't even get called, like something is blocking the eventHandler when it's some specific channels, even though the config seems to be the same on the three channels (it is a public channel; I have joined the three channels).

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: I just saw that my local node version is v19.0.0 whereas my EC2 has 21.7.0 installed. Checking now if downgrading to 19 will make a change, will update here :)

from gramjs.

onurcansevinc avatar onurcansevinc commented on July 28, 2024

I have the same problem. Has anyone found a solution?

from gramjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.