node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

What else should I do to handle the `ETIMEDOUT` error?

Open a1mersnow opened this issue 7 years ago • 1 comments

I am new here. I just follow this tutorial: https://github.com/hosein2398/node-telegram-bot-api-tutorial/blob/master/README.md

here is the code sample:

const TelegramBot = require('node-telegram-bot-api')

const token = '*********************'

const bot = new TelegramBot(token, {polling: true})

bot.on('message', msg => {
  let prefix = 'hi'
  if (msg.text.toLowerCase().indexOf(prefix) === 0) {
    bot.sendMessage(msg.chat.id, 'Hello Guy')
  }
})

when I run node indexjs, I just got error like this:

{ RequestError: Error: connect ETIMEDOUT 199.59.149.244:443 at new RequestError (C:\Users\admin\Desktop\SecretBaseBot\node_modules\request-promise-core\lib\errors .js:14:15) at Request.plumbing.callback (C:\Users\admin\Desktop\SecretBaseBot\node_modules\request-promise-core\l ib\plumbing.js:87:29) at Request.RP$callback [as _callback] (C:\Users\admin\Desktop\SecretBaseBot\node_modules\request-promi se-core\lib\plumbing.js:46:31) at self.callback (C:\Users\admin\Desktop\SecretBaseBot\node_modules\request\request.js:186:22) at emitOne (events.js:115:13) at Request.emit (events.js:210:7) at Request.onRequestError (C:\Users\admin\Desktop\SecretBaseBot\node_modules\request\request.js:878:8) at emitOne (events.js:115:13) at ClientRequest.emit (events.js:210:7) at TLSSocket.socketErrorListener (_http_client.js:400:9) at emitOne (events.js:115:13) at TLSSocket.emit (events.js:210:7) at emitErrorNT (internal/streams/destroy.js:62:8) at _combinedTickCallback (internal/process/next_tick.js:102:11) at process._tickCallback (internal/process/next_tick.js:161:9) code: 'EFATAL' }

a1mersnow avatar Oct 18 '17 03:10 a1mersnow

To me Telegram Bot API IP is 149.154.167.197. Ensure you have the network well configured.

curl -v https://api.telegram.org/bots
*   Trying 149.154.167.197...
* TCP_NODELAY set
* Connected to api.telegram.org (149.154.167.197) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: OU=Domain Control Validated; CN=api.telegram.org
*  start date: May 23 16:17:38 2015 GMT
*  expire date: May 23 16:17:38 2018 GMT
*  subjectAltName: host "api.telegram.org" matched cert's "api.telegram.org"
*  issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*  SSL certificate verify ok.
> GET /bots HTTP/1.1
> Host: api.telegram.org
> User-Agent: curl/7.55.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Server: nginx/1.10.0
< Date: Mon, 20 Nov 2017 19:32:45 GMT
< Content-Type: application/json
< Content-Length: 55
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: Content-Length,Content-Type,Date,Server,Connection
< 
* Connection #0 to host api.telegram.org left intact
{"ok":false,"error_code":404,"description":"Not Found"}

yagop avatar Nov 20 '17 19:11 yagop