yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.13k stars 1.49k forks source link

ERR_SOCKET_CONNECTION_TIMEOUT #1130

Open milad2golnia opened 9 months ago

milad2golnia commented 9 months ago

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

I want to send a file to telegram channel using following code:


    const stream = createReadStream(path);
    const contentType = mime.lookup(path);
    if (!contentType) {
      log('Error! unable to extract content type of file:', contentType);
      throw new Error('Uknown Content Type');
    }
    log(contentType);
    const result = await this.bot.sendDocument(
      chatID,
      stream,
      {},
      {
        contentType: contentType,
      }
    );
    log(result);

It is working correctly on my local machine but in server it doesn't work and raises a timeout error immediately.

Actual Behavior

When run the same code in server, I see the following message Immediately:

error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout"}
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

RequestError: Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
    at new RequestError (/home/milad/backup/node_modules/request-promise-core/lib/errors.js:14:15)
    at plumbing.callback (/home/milad/backup/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/milad/backup/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/milad/backup/node_modules/request/request.js:185:22)
    at Request.emit (node:events:511:28)
    at Request.onRequestError (/home/milad/backup/node_modules/request/request.js:877:8)
    at ClientRequest.emit (node:events:511:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:511:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EFATAL'
}

Node.js v20.2.0

Question

Is it possible that telegram is banning IP of my server? How can I make sure about it?