title: Can't catch socket hang up error of request which crashes the node server
body: <p>I have a sails server which is acting as proxy(for elasticsearch). Client server(kibana) has req timeout of 30s, when it calls a long request to proxy which takes around 50s time, it times out but that raises <code>socket hang up</code> error in the server and it crashes.</p>
  
  <p>I can increase the client timeout(which I don't feel is best), but how to catch this error?</p>
  
  <p>Proxy code looks like:</p>
  
  <pre><code>const request = require('request');
  
  function proxyRequest(req, res, esUrl) {
    let esReq = request({
      url: esUrl,
      method: req.method
    });
    esReq.on('error', function handleError(err) {
      console.log('Got error', err);
      res.json(500, {
        error: err
      });
    });
  
    return req.pipe(esReq).pipe(res);
  }
  </code></pre>
  
  <p>Above <code>error</code> event listener on <code>esReq</code> is not catching the error, I have tried adding listeners on <code>req</code> and <code>res</code> as well but doesn't work.</p>
  
  <p>Whole error is:</p>
  
  <pre><code>Error: socket hang up
  at createHangUpError (_http_client.js:253:15)
  at Socket.socketOnEnd (_http_client.js:345:23)
  at emitNone (events.js:91:20)
  at Socket.emit (events.js:185:7)
  at endReadableNT (_stream_readable.js:974:12)
  at _combinedTickCallback (internal/process/next_tick.js:80:11)
  at process._tickDomainCallback (internal/process/next_tick.js:128:9)
  </code></pre>
  
  <p>How to catch this error and handle it?</p>