request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.77k stars 297 forks source link

Error: Client network socket disconnected before secure TLS connection was established #357

Open zy-zero opened 4 years ago

zy-zero commented 4 years ago

Windows nodejs: 12.x npm: 6.x request-promise: 4.2.5 error: Client network socket disconnected before secure TLS connection was established when I create a https get(or post) request use this lab, I will get an error recently ( sometime will get the error. not always ): Client network socket disconnected before secure TLS connection was established why? Here is one I create use facebook api will get the error. same error will get when I use post method in other api.


    const options = {
        uri: `https://graph.facebook.com/v7.0/oauth/access_token?grant_type=fb_exchange_token&client_id=${client_id}&client_secret=${client_secret}&fb_exchange_token=${access_token}`,
        method: 'get',
        headers: {
        },
        json: true
    };
    try {
        refresh_res = await rp.get(options);
    } catch (e) {
        console.log(`ERROR: ${JSON.stringify(e)}`); // here will get the error.
    }
xizhu-mstr commented 3 years ago

I also meet the issue. By investigation, there are two error codes for the failed requests: ECONNRESET and EPROTO.

This affects the stability of our product seriously.

I modified the underlying request logic to add retry if the error code is ECONNRESET or EPROTO. And now our logic can work.

But it is not the root cause. Still need your team to find the cause and fix.

Marius-Ar commented 3 years ago

I'm having the same problem using the agent property making it impossible to use

JHPWBN commented 11 months ago

Hello all, I am running into the same problem:   | Client network socket disconnected before secure TLS connection was established at | connResetException (node:internal/errors:720:14) at | TLSSocket. onConnectEnd (node:_tlswrap: 1655:19)   | at TLSSocket. emit (node:events:529:35 )   | at endReadableNT (node:internal/streams/readable: 1368:12)   | at processTicksAndRejections (node: internal/process/ task

Running Homebridge 1.6.1 on Node.js Version v18.18.0 on macOS Ventura

Any thoughts on the reason would be appreciated!

Many thanks in Advance