Node-telegram-bot-api: ETELEGRAM: 502 Bad Gateway

Created on 2 Sep 2018  路  1Comment  路  Source: yagop/node-telegram-bot-api

Night some reason, there were about ten of these errors.

{ Error: ETELEGRAM: 502 Bad Gateway
    at request.then.resp (/root/node/node_modules/node-telegram-bot-api/src/telegram.js:280:15)
    at tryCatcher (/root/node/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/root/node/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/root/node/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/root/node/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/node/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/root/node/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/root/node/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/root/node/node_modules/bluebird/js/release/async.js:17:14)
    at Immediate.args.(anonymous function) (/usr/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:133:29)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
  code: 'ETELEGRAM',
  response: 
   IncomingMessage {
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [Object],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: true,
        endEmitted: true,
        reading: false,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: false,
     domain: null,
     _events: 
      { end: [Array],
        close: [Array],
        data: [Function],
        error: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     socket: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: [Object],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [Object],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: true,
        allowHalfOpen: false,
        _bytesDispatched: 10058,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [Object],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(asyncId)]: -1,
        [Symbol(bytesRead)]: 0 },
     connection: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: [Object],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [Object],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: true,
        allowHalfOpen: false,
        _bytesDispatched: 10058,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [Object],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(asyncId)]: -1,
        [Symbol(bytesRead)]: 0 },
     httpVersionMajor: 1,
     httpVersionMinor: 1,
     httpVersion: '1.1',
     complete: true,
     headers: 
      { server: 'nginx/1.12.2',
        date: 'Sat, 01 Sep 2018 01:13:42 GMT',
        'content-type': 'application/json',
        'content-length': '57',
        connection: 'keep-alive',
        'access-control-allow-origin': '*',
        'access-control-expose-headers': 'Content-Length,Content-Type,Date,Server,Connection' },
     rawHeaders: 
      [ 'Server',
        'nginx/1.12.2',
        'Date',
        'Sat, 01 Sep 2018 01:13:42 GMT',
        'Content-Type',
        'application/json',
        'Content-Length',
        '57',
        'Connection',
        'keep-alive',
        'Access-Control-Allow-Origin',
        '*',
        'Access-Control-Expose-Headers',
        'Content-Length,Content-Type,Date,Server,Connection' ],
     trailers: {},
     rawTrailers: [],
     upgrade: false,
     url: '',
     method: null,
     statusCode: 502,
     statusMessage: 'Bad Gateway',
     client: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: [Object],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [Object],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: true,
        allowHalfOpen: false,
        _bytesDispatched: 10058,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [Object],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(asyncId)]: -1,
        [Symbol(bytesRead)]: 0 },
     _consuming: true,
     _dumped: false,
     req: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: false,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: true,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /bot***/getUpdates HTTP/1.1\r\nhost: api.telegram.org\r\ncontent-type: application/x-www-form-urlencoded\r\ncontent-length: 19\r\nConnection: keep-alive\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/bot***/getUpdates',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(outHeadersKey)]: [Object] },
     request: 
      Request {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        method: 'POST',
        simple: false,
        resolveWithFullResponse: true,
        forever: true,
        readable: true,
        writable: true,
        explicitMethod: true,
        _qs: [Object],
        _auth: [Object],
        _oauth: [Object],
        _multipart: [Object],
        _redirect: [Object],
        _tunnel: [Object],
        _rp_resolve: [Function],
        _rp_reject: [Function],
        _rp_promise: [Object],
        _rp_callbackOrig: undefined,
        callback: [Function],
        _rp_options: [Object],
        headers: [Object],
        setHeader: [Function],
        hasHeader: [Function],
        getHeader: [Function],
        removeHeader: [Function],
        localAddress: undefined,
        pool: [Object],
        dests: [],
        __isRequestRequest: true,
        _callback: [Function: RP$callback],
        uri: [Object],
        proxy: null,
        tunnel: true,
        setHost: true,
        originalCookieHeader: undefined,
        _disableCookies: true,
        _jar: undefined,
        port: 443,
        host: 'api.telegram.org',
        body: 'offset=0&timeout=10',
        path: '/bot***/getUpdates',
        httpModule: [Object],
        agentClass: [Object],
        agentOptions: [Object],
        agent: [Object],
        _started: true,
        href: 'https://api.telegram.org/bot***/getUpdates',
        req: [Object],
        ntick: true,
        response: [Circular],
        originalHost: 'api.telegram.org',
        originalHostHeaderName: 'host',
        responseContent: [Circular],
        _destdata: true,
        _ended: true,
        _callbackCalled: true },
     toJSON: [Function: responseToJSON],
     caseless: Caseless { dict: [Object] },
     read: [Function],
     body: { ok: false, error_code: 502, description: 'Bad Gateway' } } }

Most helpful comment

Sometimes Telegram respond with 502 when the api server not responding, after some minutes it should works fine.

>All comments

Sometimes Telegram respond with 502 when the api server not responding, after some minutes it should works fine.

Was this page helpful?
0 / 5 - 0 ratings