Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Couldn't Auto Restart Once Encounters An Issue #55

Open
hifocus opened this issue Apr 26, 2022 · 1 comment
Open

Couldn't Auto Restart Once Encounters An Issue #55

hifocus opened this issue Apr 26, 2022 · 1 comment
Labels
issue A issue with the Bot

Comments

@hifocus
Copy link

hifocus commented Apr 26, 2022

While leaving the script in a remote machine to run, it returned the below lengthy error message after around 6-7 hours of watching

It said it returned a 400 code (Bad Request)

The remote machine has 500Mbps of bandwidth, not excellent, but due to the nature of ISP/DC network, it's meant to be more reliable than home network. And the ping looked more than fine.

root@instance-prod:~# speedtest-cli
Retrieving speedtest.net configuration...
Testing from Oracle Cloud (xxx)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Jump Networks Ltd (London) [39.19 km]: 4.22 ms
Testing download speed................................................................................
Download: 494.91 Mbit/s
Testing upload speed......................................................................................................
Upload: 289.71 Mbit/s
root@instance-prod:~# ping twitch.tv
PING twitch.tv (151.101.194.167) 56(84) bytes of data.
64 bytes from 151.101.194.167 (151.101.194.167): icmp_seq=1 ttl=58 time=1.20 ms
64 bytes from 151.101.194.167 (151.101.194.167): icmp_seq=2 ttl=58 time=1.22 ms
64 bytes from 151.101.194.167 (151.101.194.167): icmp_seq=3 ttl=58 time=1.22 ms
64 bytes from 151.101.194.167 (151.101.194.167): icmp_seq=4 ttl=58 time=1.22 ms
64 bytes from 151.101.194.167 (151.101.194.167): icmp_seq=5 ttl=58 time=1.25 ms
^C
--- twitch.tv ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 1.200/1.222/1.247/0.014 ms

Due to the nature of this error is potentially unknown, is it possible to add two features:

  • Retry the connection if the previous one failed
  • Restart the script with the same config if it encounters some error

Currently it's impossible to run and forget, as eventually it will run into some issue that needs mannual operations. Thanks.

Below are the error messages:

Watching rainbow6 | Points: 55615
Current Progress: 0 % | Watched 0/240 Minutes | Drop 1/2 | Status Active | isClaimed true
Current Progress: 74.58 % | Watched 179/240 Minutes | Drop 2/2 | Status Active | isClaimed false

ERROR: Could not load https://www.twitch.tv... Check your connection...
Unhandled Rejection at: Promise {
  <rejected> Error: Request failed with status code 400
      at createError (/root/TTVDropBot/node_modules/axios/lib/core/createError.js:16:15)
      at settle (/root/TTVDropBot/node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (/root/TTVDropBot/node_modules/axios/lib/adapters/http.js:322:11)
      at IncomingMessage.emit (node:events:538:35)
      at endReadableNT (node:internal/streams/readable:1345:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    [stack]: 'Error: Request failed with status code 400\n' +
      '    at createError (/root/TTVDropBot/node_modules/axios/lib/core/createError.js:16:15)\n' +
      '    at settle (/root/TTVDropBot/node_modules/axios/lib/core/settle.js:17:12)\n' +
      '    at IncomingMessage.handleStreamEnd (/root/TTVDropBot/node_modules/axios/lib/adapters/http.js:322:11)\n' +
      '    at IncomingMessage.emit (node:events:538:35)\n' +
      '    at endReadableNT (node:internal/streams/readable:1345:12)\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:83:21)',
    [message]: 'Request failed with status code 400',
    config: {
      transitional: {
        silentJSONParsing: true,
        forcedJSONParsing: true,
        clarifyTimeoutError: false
      },
      adapter: <ref *1> [Function: httpAdapter] {
        [length]: 1,
        [name]: 'httpAdapter',
        [prototype]: { [constructor]: [Circular *1] }
      },
      transformRequest: [
        [Function: transformRequest] {
          [length]: 2,
          [name]: 'transformRequest',
          [prototype]: [Object]
        },
        [length]: 1
      ],
      transformResponse: [
        [Function: transformResponse] {
          [length]: 1,
          [name]: 'transformResponse',
          [prototype]: [Object]
        },
        [length]: 1
      ],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: <ref *2> [Function: validateStatus] {
        [length]: 1,
        [name]: 'validateStatus',
        [prototype]: { [constructor]: [Circular *2] }
      },
      headers: {
        Accept: 'application/json, text/plain, */*',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0',
        encoding: 'utf8',
        'Client-Id': 'kimne78kx3ncx6brgo4mv6wki5h1ko',
        Authorization: ''
      },
      raxConfig: {
        retry: 3,
        noResponseRetries: 3,
        retryDelay: 60000,
        statusCodesToRetry: [ [Array], [Array], [Array], [length]: 3 ],
        httpMethodsToRetry: [
          'GET',
          'HEAD',
          'OPTIONS',
          'DELETE',
          'PUT',
          'POST',
          [length]: 6
        ],
        onRetryAttempt: [Function: onRetryAttempt] {
          [length]: 1,
          [name]: 'onRetryAttempt'
        },
        backoffType: 'static',
        currentRetryAttempt: 0,
        instance: <ref *3> [Function: wrap] {
          [length]: 0,
          [name]: 'wrap',
          [prototype]: [Object],
          request: [Function],
          getUri: [Function],
          delete: [Function],
          get: [Function],
          head: [Function],
          options: [Function],
          post: [Function],
          put: [Function],
          patch: [Function],
          defaults: [Object],
          interceptors: [Object],
          create: [Function],
          Axios: [Function],
          Cancel: [Function],
          CancelToken: [Function],
          isCancel: [Function],
          VERSION: '0.26.1',
          all: [Function],
          spread: [Function],
          isAxiosError: [Function],
          default: [Circular *3]
        },
        checkRetryAfter: true,
        maxRetryAfter: 300000
      },
      method: 'get',
      url: 'https://www.twitch.tv/rainbow6',
      data: undefined
    },
    request: <ref *5> ClientRequest {
      _events: [Object: null prototype] {
        abort: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        aborted: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        connect: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        error: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        socket: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        timeout: [Function (anonymous)] {
          [length]: 3,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        prefinish: [Function: requestOnPrefinish] {
          [length]: 0,
          [name]: 'requestOnPrefinish',
          [prototype]: [Object]
        }
      },
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [ [length]: 0 ],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: <ref *4> TLSSocket {
        _tlsOptions: {
          allowHalfOpen: undefined,
          pipe: false,
          secureContext: [SecureContext],
          isServer: false,
          requestCert: true,
          rejectUnauthorized: true,
          session: <Buffer 30 82 07 a3 02 01 01 02 02 03 04 04 02 13 02 04 20 f3 54 06 fa 86 9a 1a f1 0c bd 9b ff 0a 35 d1 92 9c 10 e7 97 2a 9a ff 32 63 72 c1 81 02 af 9b c5 04 ... 1909 more bytes>,
          ALPNProtocols: undefined,
          requestOCSP: undefined,
          enableTrace: undefined,
          pskCallback: undefined,
          highWaterMark: undefined,
          onread: undefined,
          signal: undefined
        },
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        secureConnecting: false,
        _SNICallback: null,
        servername: 'www.twitch.tv',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object: null prototype] {
          close: [Array],
          end: [Function],
          newListener: [Function],
          secure: [Function],
          session: [Function],
          free: [Function],
          timeout: [Function],
          agentRemove: [Function],
          error: [Function],
          finish: [Function]
        },
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _parent: null,
        _host: 'www.twitch.tv',
        _readableState: ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: BufferList { head: null, tail: null, length: 0 },
          length: 0,
          pipes: [Array],
          flowing: true,
          ended: false,
          endEmitted: false,
          reading: true,
          constructed: true,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          errorEmitted: false,
          emitClose: false,
          autoDestroy: true,
          destroyed: false,
          errored: null,
          closed: false,
          closeEmitted: false,
          defaultEncoding: 'utf8',
          awaitDrainWriters: null,
          multiAwaitDrain: false,
          readingMore: false,
          dataEmitted: true,
          decoder: null,
          encoding: null,
          [Symbol(kPaused)]: false,
          [pipesCount]: [Getter],
          [paused]: [Getter/Setter]
        },
        _maxListeners: undefined,
        _writableState: WritableState {
          objectMode: false,
          highWaterMark: 16384,
          finalCalled: true,
          needDrain: false,
          ending: true,
          ended: true,
          finished: false,
          destroyed: false,
          decodeStrings: false,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: false,
          bufferProcessing: false,
          onwrite: [Function],
          writecb: null,
          writelen: 0,
          afterWriteTickInfo: null,
          buffered: [Array],
          bufferedIndex: 0,
          allBuffers: true,
          allNoop: true,
          pendingcb: 1,
          constructed: true,
          prefinished: false,
          errorEmitted: false,
          emitClose: false,
          autoDestroy: true,
          errored: null,
          closed: false,
          closeEmitted: false,
          [Symbol(kOnFinished)]: [Array],
          [bufferedRequestCount]: [Getter]
        },
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: TLSWrap {
          _parent: [TCP],
          _parentWrap: undefined,
          _secureContext: [SecureContext],
          reading: true,
          onkeylog: [Function],
          onhandshakestart: [Object],
          onhandshakedone: [Function],
          onocspresponse: [Function],
          onnewsession: [Function],
          onerror: [Function],
          [Symbol(owner_symbol)]: [Circular *4],
          writeQueueSize: [Getter],
          [fd]: [Getter],
          [_externalStream]: [Getter],
          [bytesRead]: [Getter],
          [bytesWritten]: [Getter],
          isStreamBase: true
        },
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular *5],
        [Symbol(res)]: TLSWrap {
          _parent: [TCP],
          _parentWrap: undefined,
          _secureContext: [SecureContext],
          reading: true,
          onkeylog: [Function],
          onhandshakestart: [Object],
          onhandshakedone: [Function],
          onocspresponse: [Function],
          onnewsession: [Function],
          onerror: [Function],
          [Symbol(owner_symbol)]: [Circular *4],
          writeQueueSize: [Getter],
          [fd]: [Getter],
          [_externalStream]: [Getter],
          [bytesRead]: [Getter],
          [bytesWritten]: [Getter],
          isStreamBase: true
        },
        [Symbol(verified)]: true,
        [Symbol(pendingSession)]: null,
        [Symbol(async_id_symbol)]: 277678,
        [Symbol(kHandle)]: TLSWrap {
          _parent: [TCP],
          _parentWrap: undefined,
          _secureContext: [SecureContext],
          reading: true,
          onkeylog: [Function],
          onhandshakestart: [Object],
          onhandshakedone: [Function],
          onocspresponse: [Function],
          onnewsession: [Function],
          onerror: [Function],
          [Symbol(owner_symbol)]: [Circular *4],
          writeQueueSize: [Getter],
          [fd]: [Getter],
          [_externalStream]: [Getter],
          [bytesRead]: [Getter],
          [bytesWritten]: [Getter],
          isStreamBase: true
        },
        [Symbol(kSetNoDelay)]: false,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: {
          rejectUnauthorized: true,
          ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
          checkServerIdentity: [Function],
          minDHSize: 1024,
          session: <Buffer 30 82 07 a3 02 01 01 02 02 03 04 04 02 13 02 04 20 f3 54 06 fa 86 9a 1a f1 0c bd 9b ff 0a 35 d1 92 9c 10 e7 97 2a 9a ff 32 63 72 c1 81 02 af 9b c5 04 ... 1909 more bytes>,
          maxRedirects: 21,
          maxBodyLength: 10485760,
          protocol: 'https:',
          path: null,
          method: 'GET',
          headers: [Object],
          agent: undefined,
          agents: [Object],
          auth: undefined,
          hostname: 'www.twitch.tv',
          port: 443,
          nativeProtocols: [Object],
          pathname: '/rainbow6',
          _defaultAgent: [Agent],
          host: 'www.twitch.tv',
          servername: 'www.twitch.tv',
          _agentKey: 'www.twitch.tv:443:::::::::::::::::::::',
          encoding: null,
          singleUse: true
        },
        [Symbol(RequestTimeout)]: undefined,
        [_connecting]: [Getter],
        [pending]: [Getter],
        [readyState]: [Getter],
        [bufferSize]: [Getter],
        bytesRead: [Getter],
        remoteAddress: [Getter],
        remoteFamily: [Getter],
        remotePort: [Getter],
        localAddress: [Getter],
        localPort: [Getter],
        _bytesDispatched: [Getter],
        bytesWritten: [Getter],
        [_handle]: [Getter/Setter],
        [Symbol(kUpdateTimer)]: [Getter],
        [writable]: [Getter/Setter],
        [writableHighWaterMark]: [Getter],
        [writableObjectMode]: [Getter],
        [writableBuffer]: [Getter],
        [writableLength]: [Getter],
        [writableFinished]: [Getter],
        [writableCorked]: [Getter],
        [writableEnded]: [Getter],
        [writableNeedDrain]: [Getter],
        [destroyed]: [Getter/Setter]
      },
      _header: 'GET /rainbow6 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0\r\n' +
        'encoding: utf8\r\n' +
        'Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko\r\n' +
        'Authorization: ' +
        'Host: www.twitch.tv\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop] { [length]: 0, [name]: 'nop' },
      agent: Agent {
        _events: [Object: null prototype] {
          free: [Function],
          newListener: [Function]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object: null prototype] { path: null },
        requests: [Object: null prototype] {},
        sockets: [Object: null prototype] {
          'www.twitch.tv:443:::::::::::::::::::::': [Array]
        },
        freeSockets: [Object: null prototype] {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 1,
        maxCachedSessions: 100,
        _sessionCache: { map: [Object], list: [Array] },
        [Symbol(kCapture)]: false
      },
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/rainbow6',
      _ended: true,
      res: IncomingMessage {
        _readableState: ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: BufferList { head: null, tail: null, length: 0 },
          length: 0,
          pipes: [Array],
          flowing: true,
          ended: true,
          endEmitted: true,
          reading: false,
          constructed: true,
          sync: false,
          needReadable: false,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          destroyed: true,
          errored: null,
          closed: true,
          closeEmitted: true,
          defaultEncoding: 'utf8',
          awaitDrainWriters: null,
          multiAwaitDrain: false,
          readingMore: false,
          dataEmitted: true,
          decoder: null,
          encoding: null,
          [Symbol(kPaused)]: false,
          [pipesCount]: [Getter],
          [paused]: [Getter/Setter]
        },
        _events: [Object: null prototype] {
          end: [Array],
          data: [Function],
          aborted: [Function],
          error: [Function]
        },
        _eventsCount: 4,
        _maxListeners: undefined,
        socket: <ref *4> TLSSocket {
          _tlsOptions: [Object],
          _secureEstablished: true,
          _securePending: false,
          _newSessionPending: false,
          _controlReleased: true,
          secureConnecting: false,
          _SNICallback: null,
          servername: 'www.twitch.tv',
          alpnProtocol: false,
          authorized: true,
          authorizationError: null,
          encrypted: true,
          _events: [Object: null prototype],
          _eventsCount: 10,
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: 'www.twitch.tv',
          _readableState: [ReadableState],
          _maxListeners: undefined,
          _writableState: [WritableState],
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: undefined,
          _server: null,
          ssl: [TLSWrap],
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *5],
          [Symbol(res)]: [TLSWrap],
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 277678,
          [Symbol(kHandle)]: [TLSWrap],
          [Symbol(kSetNoDelay)]: false,
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: [Object],
          [Symbol(RequestTimeout)]: undefined,
          [_connecting]: [Getter],
          [pending]: [Getter],
          [readyState]: [Getter],
          [bufferSize]: [Getter],
          bytesRead: [Getter],
          remoteAddress: [Getter],
          remoteFamily: [Getter],
          remotePort: [Getter],
          localAddress: [Getter],
          localPort: [Getter],
          _bytesDispatched: [Getter],
          bytesWritten: [Getter],
          [_handle]: [Getter/Setter],
          [Symbol(kUpdateTimer)]: [Getter],
          [writable]: [Getter/Setter],
          [writableHighWaterMark]: [Getter],
          [writableObjectMode]: [Getter],
          [writableBuffer]: [Getter],
          [writableLength]: [Getter],
          [writableFinished]: [Getter],
          [writableCorked]: [Getter],
          [writableEnded]: [Getter],
          [writableNeedDrain]: [Getter],
          [destroyed]: [Getter/Setter]
        },
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        rawHeaders: [
          'Connection',
          'close',
          'Content-Type',
          'application/xml',
          'Date',
          'Mon, 25 Apr 2022 22:09:52 GMT',
          'Set-Cookie',
          'twitch.lohp.countryCode=GB; domain=.twitch.tv; expires=Sat, 20 May 2023 22:09:52 GMT;',
          'transfer-encoding',
          'chunked',
          [length]: 10
        ],
        rawTrailers: [ [length]: 0 ],
        aborted: false,
        upgrade: false,
        url: '',
        method: null,
        statusCode: 400,
        statusMessage: 'Bad Request',
        client: <ref *4> TLSSocket {
          _tlsOptions: [Object],
          _secureEstablished: true,
          _securePending: false,
          _newSessionPending: false,
          _controlReleased: true,
          secureConnecting: false,
          _SNICallback: null,
          servername: 'www.twitch.tv',
          alpnProtocol: false,
          authorized: true,
          authorizationError: null,
          encrypted: true,
          _events: [Object: null prototype],
          _eventsCount: 10,
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: 'www.twitch.tv',
          _readableState: [ReadableState],
          _maxListeners: undefined,
          _writableState: [WritableState],
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: undefined,
          _server: null,
          ssl: [TLSWrap],
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *5],
          [Symbol(res)]: [TLSWrap],
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 277678,
          [Symbol(kHandle)]: [TLSWrap],
          [Symbol(kSetNoDelay)]: false,
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: [Object],
          [Symbol(RequestTimeout)]: undefined,
          [_connecting]: [Getter],
          [pending]: [Getter],
          [readyState]: [Getter],
          [bufferSize]: [Getter],
          bytesRead: [Getter],
          remoteAddress: [Getter],
          remoteFamily: [Getter],
          remotePort: [Getter],
          localAddress: [Getter],
          localPort: [Getter],
          _bytesDispatched: [Getter],
          bytesWritten: [Getter],
          [_handle]: [Getter/Setter],
          [Symbol(kUpdateTimer)]: [Getter],
          [writable]: [Getter/Setter],
          [writableHighWaterMark]: [Getter],
          [writableObjectMode]: [Getter],
          [writableBuffer]: [Getter],
          [writableLength]: [Getter],
          [writableFinished]: [Getter],
          [writableCorked]: [Getter],
          [writableEnded]: [Getter],
          [writableNeedDrain]: [Getter],
          [destroyed]: [Getter/Setter]
        },
        _consuming: true,
        _dumped: false,
        req: [Circular *5],
        responseUrl: 'https://www.twitch.tv/rainbow6',
        redirects: [ [length]: 0 ],
        [Symbol(kCapture)]: false,
        [Symbol(kHeaders)]: {
          connection: 'close',
          'content-type': 'application/xml',
          date: 'Mon, 25 Apr 2022 22:09:52 GMT',
          'set-cookie': [Array],
          'transfer-encoding': 'chunked'
        },
        [Symbol(kHeadersCount)]: 10,
        [Symbol(kTrailers)]: null,
        [Symbol(kTrailersCount)]: 0,
        [Symbol(RequestTimeout)]: undefined,
        [connection]: [Getter/Setter],
        [headers]: [Getter/Setter],
        [trailers]: [Getter/Setter],
        [readable]: [Getter/Setter],
        [readableDidRead]: [Getter],
        [readableAborted]: [Getter],
        [readableHighWaterMark]: [Getter],
        [readableBuffer]: [Getter],
        [readableFlowing]: [Getter/Setter],
        [readableLength]: [Getter],
        [readableObjectMode]: [Getter],
        [readableEncoding]: [Getter],
        [destroyed]: [Getter/Setter],
        [readableEnded]: [Getter]
      },
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'www.twitch.tv',
      protocol: 'https:',
      _redirectable: Writable {
        _writableState: WritableState {
          objectMode: false,
          highWaterMark: 16384,
          finalCalled: false,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          destroyed: false,
          decodeStrings: true,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: true,
          bufferProcessing: false,
          onwrite: [Function],
          writecb: null,
          writelen: 0,
          afterWriteTickInfo: null,
          buffered: [Array],
          bufferedIndex: 0,
          allBuffers: true,
          allNoop: true,
          pendingcb: 0,
          constructed: true,
          prefinished: false,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          errored: null,
          closed: false,
          closeEmitted: false,
          [Symbol(kOnFinished)]: [Array],
          [bufferedRequestCount]: [Getter]
        },
        _events: [Object: null prototype] {
          response: [Function],
          error: [Function],
          socket: [Function]
        },
        _eventsCount: 3,
        _maxListeners: undefined,
        _options: {
          maxRedirects: 21,
          maxBodyLength: 10485760,
          protocol: 'https:',
          path: '/rainbow6',
          method: 'GET',
          headers: [Object],
          agent: undefined,
          agents: [Object],
          auth: undefined,
          hostname: 'www.twitch.tv',
          port: null,
          nativeProtocols: [Object],
          pathname: '/rainbow6'
        },
        _ended: true,
        _ending: true,
        _redirectCount: 0,
        _redirects: [ [length]: 0 ],
        _requestBodyLength: 0,
        _requestBodyBuffers: [ [length]: 0 ],
        _onNativeResponse: [Function (anonymous)] {
          [length]: 1,
          [name]: '',
          [arguments]: null,
          [caller]: null,
          [prototype]: [Object]
        },
        _currentRequest: [Circular *5],
        _currentUrl: 'https://www.twitch.tv/rainbow6',
        [Symbol(kCapture)]: false,
        [aborted]: [Getter],
        [connection]: [Getter],
        [socket]: [Getter],
        _writev: null,
        [destroyed]: [Getter/Setter],
        [writable]: [Getter/Setter],
        [writableFinished]: [Getter],
        [writableObjectMode]: [Getter],
        [writableBuffer]: [Getter],
        [writableEnded]: [Getter],
        [writableNeedDrain]: [Getter],
        [writableHighWaterMark]: [Getter],
        [writableCorked]: [Getter],
        [writableLength]: [Getter]
      },
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype] {
        accept: [ 'Accept', 'application/json, text/plain, */*', [length]: 2 ],
        'user-agent': [
          'User-Agent',
          'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0',
          [length]: 2
        ],
        encoding: [ 'encoding', 'utf8', [length]: 2 ],
        'client-id': [ 'Client-Id', 'kimne78kx3ncx6brgo4mv6wki5h1ko', [length]: 2 ],
        authorization: [
          'Authorization',
          '',
          [length]: 2
        ],
        host: [ 'Host', 'www.twitch.tv', [length]: 2 ]
      },
      [writableFinished]: [Getter],
      [writableObjectMode]: [Getter],
      [writableLength]: [Getter],
      [writableHighWaterMark]: [Getter],
      [writableCorked]: [Getter],
      [_headers]: [Getter/Setter],
      [connection]: [Getter/Setter],
      [_headerNames]: [Getter/Setter],
      headersSent: [Getter],
      [writableEnded]: [Getter],
      [writableNeedDrain]: [Getter]
    },
    response: {
      status: 400,
      statusText: 'Bad Request',
      headers: {
        connection: 'close',
        'content-type': 'application/xml',
        date: 'Mon, 25 Apr 2022 22:09:52 GMT',
        'set-cookie': [
          'twitch.lohp.countryCode=GB; domain=.twitch.tv; expires=Sat, 20 May 2023 22:09:52 GMT;',
          [length]: 1
        ],
        'transfer-encoding': 'chunked'
      },
      config: {
        transitional: {
          silentJSONParsing: true,
          forcedJSONParsing: true,
          clarifyTimeoutError: false
        },
        adapter: <ref *1> [Function: httpAdapter] {
          [length]: 1,
          [name]: 'httpAdapter',
          [prototype]: [Object]
        },
        transformRequest: [ [Function], [length]: 1 ],
        transformResponse: [ [Function], [length]: 1 ],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        maxBodyLength: -1,
        validateStatus: <ref *2> [Function: validateStatus] {
          [length]: 1,
          [name]: 'validateStatus',
          [prototype]: [Object]
        },
        headers: {
          Accept: 'application/json, text/plain, */*',
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0',
          encoding: 'utf8',
          'Client-Id': 'kimne78kx3ncx6brgo4mv6wki5h1ko',
          Authorization: ''
        },
        raxConfig: {
          retry: 3,
          noResponseRetries: 3,
          retryDelay: 60000,
          statusCodesToRetry: [Array],
          httpMethodsToRetry: [Array],
          onRetryAttempt: [Function],
          backoffType: 'static',
          currentRetryAttempt: 0,
          instance: [Function],
          checkRetryAfter: true,
          maxRetryAfter: 300000
        },
        method: 'get',
        url: 'https://www.twitch.tv/rainbow6',
        data: undefined
      },
      request: <ref *5> ClientRequest {
        _events: [Object: null prototype] {
          abort: [Function],
          aborted: [Function],
          connect: [Function],
          error: [Function],
          socket: [Function],
          timeout: [Function],
          prefinish: [Function]
        },
        _eventsCount: 7,
        _maxListeners: undefined,
        outputData: [ [length]: 0 ],
        outputSize: 0,
        writable: true,
        destroyed: false,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        maxRequestsOnConnectionReached: false,
        _defaultKeepAlive: true,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        _closed: false,
        socket: <ref *4> TLSSocket {
          _tlsOptions: [Object],
          _secureEstablished: true,
          _securePending: false,
          _newSessionPending: false,
          _controlReleased: true,
          secureConnecting: false,
          _SNICallback: null,
          servername: 'www.twitch.tv',
          alpnProtocol: false,
          authorized: true,
          authorizationError: null,
          encrypted: true,
          _events: [Object: null prototype],
          _eventsCount: 10,
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: 'www.twitch.tv',
          _readableState: [ReadableState],
          _maxListeners: undefined,
          _writableState: [WritableState],
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: undefined,
          _server: null,
          ssl: [TLSWrap],
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *5],
          [Symbol(res)]: [TLSWrap],
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 277678,
          [Symbol(kHandle)]: [TLSWrap],
          [Symbol(kSetNoDelay)]: false,
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: [Object],
          [Symbol(RequestTimeout)]: undefined,
          [_connecting]: [Getter],
          [pending]: [Getter],
          [readyState]: [Getter],
          [bufferSize]: [Getter],
          bytesRead: [Getter],
          remoteAddress: [Getter],
          remoteFamily: [Getter],
          remotePort: [Getter],
          localAddress: [Getter],
          localPort: [Getter],
          _bytesDispatched: [Getter],
          bytesWritten: [Getter],
          [_handle]: [Getter/Setter],
          [Symbol(kUpdateTimer)]: [Getter],
          [writable]: [Getter/Setter],
          [writableHighWaterMark]: [Getter],
          [writableObjectMode]: [Getter],
          [writableBuffer]: [Getter],
          [writableLength]: [Getter],
          [writableFinished]: [Getter],
          [writableCorked]: [Getter],
          [writableEnded]: [Getter],
          [writableNeedDrain]: [Getter],
          [destroyed]: [Getter/Setter]
        },
        _header: 'GET /rainbow6 HTTP/1.1\r\n' +
          'Accept: application/json, text/plain, */*\r\n' +
          'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0\r\n' +
          'encoding: utf8\r\n' +
          'Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko\r\n' +
          'Authorization: ' +
          'Host: www.twitch.tv\r\n' +
          'Connection: close\r\n' +
          '\r\n',
        _keepAliveTimeout: 0,
        _onPendingData: [Function: nop] { [length]: 0, [name]: 'nop' },
        agent: Agent {
          _events: [Object: null prototype],
          _eventsCount: 2,
          _maxListeners: undefined,
          defaultPort: 443,
          protocol: 'https:',
          options: [Object: null prototype],
          requests: [Object: null prototype] {},
          sockets: [Object: null prototype],
          freeSockets: [Object: null prototype] {},
          keepAliveMsecs: 1000,
          keepAlive: false,
          maxSockets: Infinity,
          maxFreeSockets: 256,
          scheduling: 'lifo',
          maxTotalSockets: Infinity,
          totalSocketCount: 1,
          maxCachedSessions: 100,
          _sessionCache: [Object],
          [Symbol(kCapture)]: false
        },
        socketPath: undefined,
        method: 'GET',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: '/rainbow6',
        _ended: true,
        res: IncomingMessage {
          _readableState: [ReadableState],
          _events: [Object: null prototype],
          _eventsCount: 4,
          _maxListeners: undefined,
          socket: [TLSSocket],
          httpVersionMajor: 1,
          httpVersionMinor: 1,
          httpVersion: '1.1',
          complete: true,
          rawHeaders: [Array],
          rawTrailers: [Array],
          aborted: false,
          upgrade: false,
          url: '',
          method: null,
          statusCode: 400,
          statusMessage: 'Bad Request',
          client: [TLSSocket],
          _consuming: true,
          _dumped: false,
          req: [Circular *5],
          responseUrl: 'https://www.twitch.tv/rainbow6',
          redirects: [Array],
          [Symbol(kCapture)]: false,
          [Symbol(kHeaders)]: [Object],
          [Symbol(kHeadersCount)]: 10,
          [Symbol(kTrailers)]: null,
          [Symbol(kTrailersCount)]: 0,
          [Symbol(RequestTimeout)]: undefined,
          [connection]: [Getter/Setter],
          [headers]: [Getter/Setter],
          [trailers]: [Getter/Setter],
          [readable]: [Getter/Setter],
          [readableDidRead]: [Getter],
          [readableAborted]: [Getter],
          [readableHighWaterMark]: [Getter],
          [readableBuffer]: [Getter],
          [readableFlowing]: [Getter/Setter],
          [readableLength]: [Getter],
          [readableObjectMode]: [Getter],
          [readableEncoding]: [Getter],
          [destroyed]: [Getter/Setter],
          [readableEnded]: [Getter]
        },
        aborted: false,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: false,
        host: 'www.twitch.tv',
        protocol: 'https:',
        _redirectable: Writable {
          _writableState: [WritableState],
          _events: [Object: null prototype],
          _eventsCount: 3,
          _maxListeners: undefined,
          _options: [Object],
          _ended: true,
          _ending: true,
          _redirectCount: 0,
          _redirects: [Array],
          _requestBodyLength: 0,
          _requestBodyBuffers: [Array],
          _onNativeResponse: [Function],
          _currentRequest: [Circular *5],
          _currentUrl: 'https://www.twitch.tv/rainbow6',
          [Symbol(kCapture)]: false,
          [aborted]: [Getter],
          [connection]: [Getter],
          [socket]: [Getter],
          _writev: null,
          [destroyed]: [Getter/Setter],
          [writable]: [Getter/Setter],
          [writableFinished]: [Getter],
          [writableObjectMode]: [Getter],
          [writableBuffer]: [Getter],
          [writableEnded]: [Getter],
          [writableNeedDrain]: [Getter],
          [writableHighWaterMark]: [Getter],
          [writableCorked]: [Getter],
          [writableLength]: [Getter]
        },
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype] {
          accept: [Array],
          'user-agent': [Array],
          encoding: [Array],
          'client-id': [Array],
          authorization: [Array],
          host: [Array]
        },
        [writableFinished]: [Getter],
        [writableObjectMode]: [Getter],
        [writableLength]: [Getter],
        [writableHighWaterMark]: [Getter],
        [writableCorked]: [Getter],
        [_headers]: [Getter/Setter],
        [connection]: [Getter/Setter],
        [_headerNames]: [Getter/Setter],
        headersSent: [Getter],
        [writableEnded]: [Getter],
        [writableNeedDrain]: [Getter]
      },
      data: '<?xml version="1.0" encoding="UTF-8"?>\n' +
        '<Error></Error>'
    },
    isAxiosError: true,
    toJSON: <ref *6> [Function: toJSON] {
      [length]: 0,
      [name]: 'toJSON',
      [prototype]: { [constructor]: [Circular *6] }
    }
  }
}
Unhandled Rejection Reason: Error: Request failed with status code 400
root@instance-prod:~/TTVDropBot# client_loop: send disconnect: Connection reset
@hifocus hifocus changed the title Couldn't Auto Restart Once Encountered An Issue Couldn't Auto Restart Once Encounters An Issue Apr 26, 2022
@Zaarrg
Copy link
Owner

Zaarrg commented May 2, 2022

Will definitely look into that, The bot retries requests up to 4 times but in your case a 400 bad request is not retried, because it would fail anyway after 4 tries. Either an incorrect DNS entries or wrong header or URL. Checked the URL and header in the error, and they seem fine, so it's probably a problem on your end. Sadly, there could be more to that error, so it is quite hard to identify exactly what's the cause. But I can say with certainty that the request should have worked, it has the right URL and right header.

And about restarting, you should use a process manager for that like pm2.

@Zaarrg Zaarrg added the issue A issue with the Bot label May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue A issue with the Bot
Projects
None yet
Development

No branches or pull requests

2 participants