Ошибка сброса электронного соединения на getInitialProps при запросе с сервера - PullRequest
0 голосов
/ 14 октября 2019

Я пытаюсь отправить запрос к API ниже: https://stagecore.mentorz.com:8443/mentorz/api/v3/user/0/trendingmentors

И иногда я получаю сообщение об ошибке ECONNRESET при запросе API с сервера. Но это не репликация при звонке с клиента (браузера) или почтальона. Также иногда работает то же самое. API работает 6 из 10 раз при обновлении страницы. Я попытался увеличить время ожидания для node.js и переключения сетей и еще много чего, и, похоже, ничего не работает. Найдите ниже трассировку стека, которую я получаю от объекта ошибки axios.

{ name: 'Error',
  message: 'read ECONNRESET',
  stack:
   'Error: read ECONNRESET\n    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)',
  toJSON: [Function],
  isAxiosError: true,
  response: undefined,
  request:
   { _currentUrl:
      'https://stagecore.mentorz.com:8443/mentorz/api/v3/user/0/trendingmentors?offset=0&limit=10',
     _currentRequest:
      { _redirectable: '[Circular]',
        maxHeadersCount: null,
        parser: null,
        upgradeOrConnect: false,
        timeoutCb: null,
        aborted: undefined,
        res: null,
        _ended: false,
        path: '/mentorz/api/v3/user/0/trendingmentors?offset=0&limit=10',
        method: 'GET',
        timeout: undefined,
        socketPath: undefined,
        agent: [Object],
        _onPendingData: [Function: noopPendingOutput],
        _header:
         'GET /mentorz/api/v3/user/0/trendingmentors?offset=0&limit=10 HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36\r\nHost: stagecore.mentorz.com:8443\r\nConnection: close\r\n\r\n',
        connection: [Object],
        socket: [Object],
        _headerSent: true,
        finished: true,
        _trailer: '',
        _hasBody: true,
        _contentLength: 0,
        _removedTE: false,
        _removedContLen: false,
        _removedConnection: false,
        sendDate: false,
        useChunkedEncodingByDefault: false,
        shouldKeepAlive: false,
        chunkedEncoding: false,
        _last: true,
        writable: true,
        outputSize: 0,
        outputCallbacks: [],
        outputEncodings: [],
        output: [],
        _maxListeners: undefined,
        _eventsCount: 6,
        _events: [Object] },
     _onNativeResponse: [Function],
     _requestBodyBuffers: [],
     _requestBodyLength: 0,
     _redirects: [],
     _redirectCount: 0,
     _options:
      { search: '?offset=0&limit=10',
        pathname: '/mentorz/api/v3/user/0/trendingmentors',
        nativeProtocols: [Object],
        port: '8443',
        hostname: 'stagecore.mentorz.com',
        auth: undefined,
        agent: undefined,
        headers: [Object],
        method: 'GET',
        path: '/mentorz/api/v3/user/0/trendingmentors?offset=0&limit=10',
        maxBodyLength: 10485760,
        maxRedirects: 21,
        protocol: 'https:' },
     _maxListeners: undefined,
     _eventsCount: 2,
     _events:
      { error: [Function: handleRequestError],
        response: [Function: handleResponse] },
     writable: true,
     _writableState:
      { corkedRequestsFree: [Object],
        bufferedRequestCount: 0,
        autoDestroy: false,
        emitClose: true,
        errorEmitted: false,
        prefinished: false,
        pendingcb: 0,
        lastBufferedRequest: null,
        bufferedRequest: null,
        writelen: 0,
        writecb: null,
        onwrite: [Function: bound onwrite],
        bufferProcessing: false,
        sync: true,
        corked: 0,
        writing: false,
        length: 0,
        defaultEncoding: 'utf8',
        decodeStrings: true,
        destroyed: false,
        finished: false,
        ended: false,
        ending: false,
        needDrain: false,
        finalCalled: false,
        highWaterMark: 16384,
        objectMode: false } },
  config:
   { data: undefined,
     validateStatus: [Function: validateStatus],
     maxContentLength: -1,
     xsrfHeaderName: 'X-XSRF-TOKEN',
     xsrfCookieName: 'XSRF-TOKEN',
     adapter: [Function: httpAdapter],
     timeout: 0,
     transformResponse: [ [Function: transformResponse] ],
     transformRequest: [ [Function: transformRequest] ],
     baseURL: 'https://stagecore.mentorz.com:8443/mentorz/api',
     headers:
      { 'user-agent':
         'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
        Accept: 'application/json, text/plain, */*' },
     params: { limit: 10, offset: 0 },
     method: 'get',
     url:
      'https://stagecore.mentorz.com:8443/mentorz/api/v3/user/0/trendingmentors' },
  syscall: 'read',
  code: 'ECONNRESET',
  errno: 'ECONNRESET' }
...