Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E-connection reset error on getInitialProps when requestion from server. #9006

Closed
mnksingh1996 opened this issue Oct 9, 2019 · 9 comments
Closed

Comments

@mnksingh1996
Copy link

Hi,
I am trying to send request to the below api:
https://stagecore.mentorz.com:8443/mentorz/api/v3/user/0/trendingmentors

And I am sometimes getting ECONNRESET error when requesting the api from server. But it is not replicating when calling from client(browser) or postman.
Also Sometimes the same thing works. The api works 6 out of 10 times on page refresh.
I have tried increasing timeout of node.js and switching networks and whatnot and nothing seems to work. Please find below the stack trace I am getting from axios error object.

{ 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' }
@timneutkens
Copy link
Member

Please follow the issue template.

https://github.com/zeit/next.js/issues/new/choose

https://github.com/zeit/next.js/issues/new?template=8.Question_about_next.md

# Question about Next.js

GitHub Issues are reserved for Bug reports and Feature requests. The best place to get your question answered is to post it on https://spectrum.chat/next-js.

@rajneesh3923
Copy link

@para27rsh did you find the solution???. I am also experiencing this issue.

@rajneesh3923
Copy link

@mnksingh1996 did you find the solution???. I am also experiencing this issue.

@Lefcott
Copy link

Lefcott commented Feb 13, 2021

Hey! Same issue over here.
image
image

@feluxe
Copy link

feluxe commented Feb 27, 2021

I'm stuck with this as well.. Any news?

I tried with NodeJs 12, 14, and 15 without luck.

It happens when I run my nextjs (v10.0.7) app in a Debian slim-buster docker container with env production.

It cannot reproduce this locally.

@Lefcott
Copy link

Lefcott commented Feb 27, 2021

I tried with axios and fetch and the error is similar. I stopped using getInitialProps for now.

@matt-dalton
Copy link

matt-dalton commented Nov 9, 2021

Did anyone fix this? I'm having the same issue since Next JS 11.

In my case it's when I'm running two fetch calls in the same block of code fairly close together (they're both preceded by await, so they don't overlap). The second call consistently fails.

@matt-dalton
Copy link

Ahhh I've found my issue. In case this helps anyone, I eventually discovered in NextJS 11 keep-alive was added by default. There is now an option to turn this off in the Next config., so i just set it back to false.

I'd initially struggled to turn this off in express because I have a custom server.

@sadeghhosseiny
Copy link

hi everyone
i want to fetch api with next js but i got this error -> FetchError: request to https://api.themoviedb.org/3/discover/movie?api_key=cd7789*******************&with_genres=27 failed, reason: read ECONNRESET
what should i do ??
i replace the api with jsonPlaceholder and it worked i dont know why this api not working.
help me please....

@vercel vercel locked as resolved and limited conversation to collaborators Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants