8

I am getting socket hang up eror message while sending request. As per observation request is getting processed but at the time of sending response, I am getting below response:

 {
   "success":false,
   "error":{
     "name":"RequestError","message":"Error: socket hang up","cause":{"code":"ECONNRESET"},
     "error":{"code":"ECONNRESET"},
     "options":{"uri":"request url","simple":true,"resolveWithFullResponse":false,"transform2xxOnly":false}
   }
}

I am using below code:

var options = {
  uri: 'request url',
};
request(options).then(function(data) {
    res.json({
      success: true,
      data: data
    });     
 })
 .catch(function (err) {
    res.json({
      success: false,
      error: err,
    });
});
alexmac
  • 19,087
  • 7
  • 58
  • 69
charmi zala
  • 113
  • 1
  • 2
  • 12
  • 1
    Possible duplicate of [NodeJS - What does "socket hang up" actually mean?](https://stackoverflow.com/questions/16995184/nodejs-what-does-socket-hang-up-actually-mean) – alexmac Aug 09 '17 at 09:57
  • Your code seems to be fine. Can you please share your URI if not confidential and your handler code to debug more? – node_saini Aug 09 '17 at 10:56
  • @node_saini URL is confidential so I cannot share it.. But the problem is related to timeout. Process is taking upto 6 minutes and request is not waiting for that and giving this error. If you have experienced timeout issue then you can share your solution – charmi zala Aug 10 '17 at 06:56
  • 1
    You can try using `server.timeout` or `server.keepAliveTimeout` – node_saini Aug 10 '17 at 10:39
  • @charmizala i dont think its a time out problem else you would have seen `ETIMEDOUT` , but im also facing the same problem my api call works via `request-promise` module perfectly and just once a week i see the error `ECONNRESET`, which is new, it never use to happen. – Ylama Sep 16 '21 at 10:58
  • almost feels like blaming module `request-promise` as i see people move away from it and it fixes the problem. – Ylama Sep 16 '21 at 11:00

0 Answers0