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

Telegram session frequently logs out when running on Google Cloud VM #773

Open
RodaBVB opened this issue Feb 5, 2025 · 3 comments
Open

Comments

@RodaBVB
Copy link

RodaBVB commented Feb 5, 2025

Description
I am experiencing an issue where my Telegram session frequently logs out when running on a Google Cloud VM (static IP) using GramJS. Every time I log in, Telegram detects the login attempt as potentially malicious and forcibly logs me out after a short period.

I suspect this is happening because Telegram flags Google Cloud IPs as untrusted due to potential abuse. This does not happen when running the same code on a local machine or a different cloud provider.

Steps to Reproduce

  1. Deploy a Node.js server using GramJS on a Google Cloud VM (Europe region, static IP)
  2. Authenticate a Telegram user session
  3. Perform basic API calls (e.g., client.getMe())
  4. After some time, Telegram forcefully logs out the session

Expected Behavior

  • The session should remain active unless manually logged out
  • Telegram should not falsely flag the session as malicious

Observed Behavior

  • Telegram frequently logs out the session, treating it as an unauthorized login
  • Logging in multiple times creates multiple session files, even though I am using session persistence

Additional Information

  • GramJS Version: 2.17.4
  • Node.js Version: v16.14.2
  • OS: Ubuntu 22.04.5 LTS (Google Cloud VM)
  • Google Cloud Region: europe-west1-b
  • Static IP: Yes

Troubleshooting Attempts

✅ Tested the same setup on a local machine (works fine)
✅ Tried using a different cloud provider (works fine)
✅ Changed the session file storage method (issue persists)
✅ Contacted Telegram support (awaiting response)
✅ I also tried adding parameters such as deviceModel, systemVersion, appVersion

const client_options = {
  deviceModel: `${pkg.name}@${os.hostname()}`,
  systemVersion: os.version() || "Unknown node",
  appVersion: pkg.version,
  useWSS: true,
  testServers: false,
  connectionRetries: 99
};

const myClient = new TelegramClient(session.sessionName, apiId, apiHash, client_options);

Questions

  1. Has anyone else experienced this issue when running on Google Cloud?
  2. Is there a way to make GramJS sessions more persistent on Google Cloud?
  3. Any workarounds to prevent Telegram from flagging my Google Cloud IP as malicious?
@MounibCS
Copy link

MounibCS commented Feb 5, 2025

Same exact scenario here, But in an Azure VM.

@RodaBVB
Copy link
Author

RodaBVB commented Feb 6, 2025

@MounibCS Have you found a solution? Please let me know if you've discovered anything, as I can't find adequate support from Telegram.

@bigbigsir
Copy link

Ban the account?

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

3 participants