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 connection #1562

Open
ALGOREX-PH opened this issue Dec 29, 2024 · 8 comments
Open

Telegram connection #1562

ALGOREX-PH opened this issue Dec 29, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@ALGOREX-PH
Copy link

How can I fix this?

I just added my telegram bot token and character.ts clients to Add telegram.

However when I pnpm start I get this error :

“ SUCCESS
SUCCESS
Creating runtime for character
Hikari

✓ SUCCESS
Agent ID
1004db53-bf1b-0d1a-ba4c-01d318a8197d

["✓ Registering action: CONTINUE"]

["✓ Registering action: FOLLOW_ROOM"]

["✓ Registering action: UNFOLLOW_ROOM"]

["✓ Registering action: IGNORE"]

["✓ Registering action: NONE"]

["✓ Registering action: MUTE_ROOM"]

["✓ Registering action: UNMUTE_ROOM"]

â—Ž LOGS
Registering service:
browser

â—Ž LOGS
Registering service:
image_description

â—Ž LOGS
Registering service:
text_generation

â—Ž LOGS
Registering service:
pdf

â—Ž LOGS
Registering service:
speech_generation

â—Ž LOGS
Registering service:
transcription

â—Ž LOGS
Registering service:
video

["✓ Server running at http://localhost:3000/"]

["✓ Service browser initialized successfully"]

["✓ Service image_description initialized successfully"]

["✓ Service text_generation initialized successfully"]

["✓ Service pdf initialized successfully"]

["✓ Service speech_generation initialized successfully"]

["✓ Service transcription initialized successfully"]

["✓ Service video initialized successfully"]

["◎ 📱 Constructing new TelegramClient..."]

["◎ ✅ TelegramClient constructor completed"]

["◎ 🚀 Starting Telegram bot..."]

["◎ ✨ Telegram bot successfully launched and is running!"]

â›” ERRORS
� Failed to launch Telegram bot:
{"message":"request to https://api.telegram.org/bot7813398684:[REDACTED]/getMe failed, reason: ","type":"system","errno":"ETIMEDOUT","code":"ETIMEDOUT"}

â›” ERRORS
Error starting agent for character Hikari:
{"message":"request to https://api.telegram.org/bot7813398684:[REDACTED]/getMe failed, reason: ","type":"system","errno":"ETIMEDOUT","code":"ETIMEDOUT"}

FetchError: request to https://api.telegram.org/bot7813398684:[REDACTED]/getMe failed, reason:
at ClientRequest. (/home/algorex/eliza-starter/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:524:28)
at emitErrorEvent (node:_http_client:104:11)
at TLSSocket.socketErrorListener (node:_http_client:512:5)
at TLSSocket.emit (node:events:524:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:90:21)
at runNextTicks (node:internal/process/task_queues:69:3)
at listOnTimeout (node:internal/timers:555:9) {
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT'
}
â›” ERRORS
Error starting agents:
{"message":"request to https://api.telegram.org/bot7813398684:[REDACTED]/getMe failed, reason: ","type":"system","errno":"ETIMEDOUT","code":"ETIMEDOUT"}

["â—Ž Chat started. Type 'exit' to quit."]

You:
/home/algorex/eliza-starter/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js:1501
reject(new FetchError(request to ${request.url} failed, reason: ${err.message}, 'system', err));
^
FetchError: request to https://api.telegram.org/bot7813398684:[REDACTED]/getMe failed, reason:
at ClientRequest. (/home/algorex/eliza-starter/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:524:28)
at emitErrorEvent (node:_http_client:104:11)
at TLSSocket.socketErrorListener (node:_http_client:512:5)
at TLSSocket.emit (node:events:524:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT'
}

Node.js v22.12.0
 ELIFECYCLE  Command failed with exit code 1.

@ALGOREX-PH ALGOREX-PH added the bug Something isn't working label Dec 29, 2024
Copy link

Hello @ALGOREX-PH! Welcome to the ai16z community. Thank you for opening your first issue; we appreciate your contribution. You are now a ai16z contributor!

@AIFlowML
Copy link
Contributor

Based on the code from the telegramClient.ts file, the issue you're experiencing seems to be related to a timeout error when the Telegram bot tries to connect to the Telegram API. Here are some steps you can take to troubleshoot and potentially resolve this issue:

Check Network Connectivity: Ensure that your server or local machine has a stable internet connection. The ETIMEDOUT error indicates that the request to the Telegram API is timing out, which could be due to network issues.

Verify Telegram Bot Token: Double-check that the bot token you are using is correct. An incorrect token could lead to failed API requests.

API Endpoint Accessibility: Make sure that the Telegram API endpoint (https://api.telegram.org) is accessible from your network. You can test this by trying to access the endpoint using a tool like curl or a web browser.

Firewall and Security Groups: If you're running this on a cloud server, ensure that your firewall or security groups are not blocking outbound requests to the Telegram API.

Proxy Settings: If your network requires a proxy to access the internet, ensure that your application is configured to use it.

@jiaohu
Copy link

jiaohu commented Dec 31, 2024

Based on the code from the telegramClient.ts file, the issue you're experiencing seems to be related to a timeout error when the Telegram bot tries to connect to the Telegram API. Here are some steps you can take to troubleshoot and potentially resolve this issue:

Check Network Connectivity: Ensure that your server or local machine has a stable internet connection. The ETIMEDOUT error indicates that the request to the Telegram API is timing out, which could be due to network issues.

Verify Telegram Bot Token: Double-check that the bot token you are using is correct. An incorrect token could lead to failed API requests.

API Endpoint Accessibility: Make sure that the Telegram API endpoint (https://api.telegram.org) is accessible from your network. You can test this by trying to access the endpoint using a tool like curl or a web browser.

Firewall and Security Groups: If you're running this on a cloud server, ensure that your firewall or security groups are not blocking outbound requests to the Telegram API.

Proxy Settings: If your network requires a proxy to access the internet, ensure that your application is configured to use it.

I have added proxy in

this.bot = new Telegraf(botToken);
like this

        this.bot = new Telegraf(botToken, {
            telegram: {
              agent: new HttpsProxyAgent("http://127.0.0.1:7890"),
            },
          });

but it does not work well, and I am sure this method works well, for I have did the same thing in my own telegram project

@harjotjuneja6
Copy link

Hi , is this issue fixed or it needs to be fixed ?

@jiaohu
Copy link

jiaohu commented Jan 2, 2025

Hi , is this issue fixed or it needs to be fixed ?

do not fixed yet

@AIFlowML
Copy link
Contributor

AIFlowML commented Jan 2, 2025

Can you remove the proxy and try a run ? Can you add logging on that proxy to see if the error is originated by the client or by the proxy ? Some proxies are banned or IP sensitive.

@alwaysabetterway
Copy link

well how about making sure that you can connect from the server first, try:

curl -X GET "https://api.telegram.org/$BOTIDGOESHERE:$YOURBOTTOKENGOESHERE/getMe"

If you get a response with the information from your bot, then it seems to connect ok. I'm having the same error me
ssage but I think this is something else, maybe it just times out too quickly. I'll try to debug it.

@alwaysabetterway
Copy link

Can you remove the proxy and try a run ? Can you add logging on that proxy to see if the error is originated by the client or by the proxy ? Some proxies are banned or IP sensitive.

w/o the proxy it fails as shown above ETIMEOUT,

I added more logs:

        this.bot = new Telegraf(botToken, {
            telegram: {
              agent: new HttpsProxyAgent("http://127.0.0.1:7890").on('error', (err) => {
                console.error('Proxy Error:', err);
              }).on('connect', (response, socket, head) => {
                console.log('Proxy Connected:', response.statusCode);
              })
            },
           });

but it just hands at

 ["ℹ Initializing LlamaService..."]

Initializing AwsS3Service
 ◎ LOGS
   initializeClients
   ["twitter","telegram"]
   for
   xxxxx

 ["◎ 📱 Constructing new TelegramClient..."]

 ["◎ ✅ TelegramClient constructor completed"]

 ["◎ 🚀 Starting Telegram bot..."]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants