title: socket hang up when doing several http requests inside my flow
body: <p>I'm having an issue in Node-red when in my flow I have several http requests to another services in my node-red. As far as I can see the error always comes when I do the second call to the same domain (i.e.: localhost, although it could be with another domain)</p>
  
  <p>As summary: I have 2 different flows:</p>
  
  <ul>
  <li>One as a gitlab interface for retrieving files from there. So from here I call to the gitlab server (<a href="https://i.stack.imgur.com/9uPEw.png" rel="nofollow noreferrer">Flow 1</a>)</li>
  <li>Another one my application, that needs to retrieve 2 different files. From this flow, I call 2 times to the previous flow (<a href="https://i.stack.imgur.com/izOzn.png" rel="nofollow noreferrer">Flow 2</a>)</li>
  </ul>
  
  <p>So, once my second flow is started, and after some JavaScript and switch nodes, I call by the first time to to first flow, which calls to gitlab. This works absolutely fine
  The second flow continues and calls again, after another JavaScript nodes, to the first flow, and it seems that the flow is freezes and nothing happens, and after 2 minutes I get this error:</p>
  
  <pre><code>4 Apr 16:18:11 - [error] [http request:get_file] no response from server
  4 Apr 16:18:11 - [error] [http request:get_file] Error: socket hang up
  4 Apr 16:18:11 - [warn] [function:prepare_output] [navigations 3ef90eaf.c106f2] Error retrieving the data from the storage
  Error: socket hang up : http://localhost:1880/gitlab_interface/file?...
  4 Apr 16:18:11 - [warn] [function:init] [navigations 3ef90eaf.c106f2] Let's raise an error: ECONNRESET | Error retrieving the data from the storage
  4 Apr 16:18:11 - [info] [function:init] [navigations 3ef90eaf.c106f2] Error raised: ECONNRESET | Error retrieving the data from the storage
  Error: request aborted
  at IncomingMessage.onAborted (...\node-red-0.16.2\node_modules\body-parser\node_modules\raw-body\index.js:269:10)
  at emitNone (events.js:67:13)
  at IncomingMessage.emit (events.js:166:7)
  at abortIncoming (_http_server.js:280:11)
  at Socket.serverSocketCloseListener (_http_server.js:293:5)
  at emitOne (events.js:82:20)
  at Socket.emit (events.js:169:7)
  at TCP._onclose (net.js:477:12)
  </code></pre>
  
  <p>Do you have an idea what could be the error?</p>
  
  <p>I've searched in internet about this error in nodejs, for instance:</p>
  
  <p><a href="https://stackoverflow.com/questions/41241938/nodejs-socket-hang-up-econnreset-http-post-request-from-meteor-to-node-js-se">Nodejs Socket hang up &amp; ECONNRESET - HTTP post request from Meteor to Node js server</a>
  <a href="https://stackoverflow.com/questions/18692580/node-js-post-causes-error-socket-hang-up-code-econnreset">Node.js POST causes [Error: socket hang up] code: &#39;ECONNRESET&#39;</a>
  <a href="https://stackoverflow.com/questions/17245881/node-js-econnreset">Node js ECONNRESET</a>
  I've been testing locally some of these possible solutions (modifying the library <em>follow-redirects</em> and the node <em>21-httprequest.js</em>) but without any success, so I'm lost about why this error occurs</p>
  
  <p>I've tried also to set a delay, just to be sure that it's not a timing issue</p>
  
  <p>I'm using node-red v0.16.2 and nodejs v4.4.3</p>
  
  <p>Thanks in advance,
  regards.</p>
  
  <p>PS: I've done a test with metrics active:</p>
  
  <pre><code>λ node red.js
  5 Apr 18:17:31 - [info]
  
  Welcome to Node-RED
  ===================
  
  5 Apr 18:17:31 - [info] Node-RED version: v0.16.2
  5 Apr 18:17:31 - [info] Node.js  version: v4.4.3
  5 Apr 18:17:31 - [info] Windows_NT 6.1.7601 x64 LE
  5 Apr 18:17:32 - [info] Loading palette nodes
  5 Apr 18:17:34 - [warn] ------------------------------------------------------
  5 Apr 18:17:34 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
  5 Apr 18:17:34 - [warn] [tail] Not currently supported on Windows.
  5 Apr 18:17:34 - [warn] ------------------------------------------------------
  5 Apr 18:17:34 - [info] Settings file  : C:\Users\myuser\.node-red\settings.js
  5 Apr 18:17:34 - [info] User directory : C:\Users\myuser\.node-red
  5 Apr 18:17:34 - [info] Flows file     : C:\Users\myuser\.node-red\flows_LAPTOP.json
  5 Apr 18:17:34 - [info] Server now running at http://127.0.0.1:1880/
  5 Apr 18:17:34 - [debug] loaded flow revision: 2c8bff6298ad76b74c43e90797e50981
  5 Apr 18:17:34 - [debug] red/runtime/nodes/credentials.load : no user key present
  5 Apr 18:17:34 - [debug] red/runtime/nodes/credentials.load : using default key
  5 Apr 18:17:34 - [info] Starting flows
  5 Apr 18:17:34 - [info] Started flows
  5 Apr 18:17:34 - [audit] {"event":"comms.open","level":98,"timestamp":1491409054876}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"eb5384b9.2266c8","event":"node.http in.send","msgid":"1a5f4041.e5a0c","timestamp":1491409060573}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"25a9b4b.377a64c","event":"node.function.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409060575}
  5 Apr 18:17:40 - [info] [function:init] [flow2 1a5f4041.e5a0c] URL: '/mygroup/mysecondflow?query=string' | Headers JSON: '{"host":"localhost:1880","connection":"keep-alive","cache-control":"no-cache","user-agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36","postman-token":"e84cf5b7-2d90-af9f-7367-93e758b5fbf1","accept":"*/*","accept-encoding":"gzip, deflate, sdch, br","accept-language":"en-US,en;q=0.8"}'
  5 Apr 18:17:40 - [info] [function:init] [flow2 1a5f4041.e5a0c] Received token: undefined
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"25a9b4b.377a64c","event":"node.function.send","msgid":"1a5f4041.e5a0c","timestamp":1491409060585}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"a03d1790.77f638","event":"node.function.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409060586}
  5 Apr 18:17:40 - [info] [function:validations] [flow2 1a5f4041.e5a0c] 'ok'
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"a03d1790.77f638","event":"node.function.send","msgid":"1a5f4041.e5a0c","timestamp":1491409060588}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"4911f030.be699","event":"node.switch.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409060589}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"4911f030.be699","event":"node.switch.send","msgid":"1a5f4041.e5a0c","timestamp":1491409060593}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"3d1c9dd1.ab5c02","event":"node.switch.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409060594}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"3d1c9dd1.ab5c02","event":"node.switch.send","msgid":"1a5f4041.e5a0c","timestamp":1491409060596}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"404be498.cbc77c","event":"node.http request.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409060597}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"a03d1790.77f638","event":"node.function.duration","msgid":"1a5f4041.e5a0c","value":40.66,"timestamp":1491409060628}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"25a9b4b.377a64c","event":"node.function.duration","msgid":"1a5f4041.e5a0c","value":52.38,"timestamp":1491409060629}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"fbe50847.a50258","event":"node.http in.send","msgid":"81687733.7e9788","timestamp":1491409060644}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"4aa21f88.5424d","event":"node.function.receive","msgid":"81687733.7e9788","timestamp":1491409060645}
  5 Apr 18:17:40 - [info] [function:init] [flow1 81687733.7e9788] URL: '/gitlab_interface/file?query=string' | Headers JSON: '{"host":"localhost:1880","connection":"close"}'
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"4aa21f88.5424d","event":"node.function.send","msgid":"81687733.7e9788","timestamp":1491409060653}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"7fe7c062.5373b","event":"node.function.receive","msgid":"81687733.7e9788","timestamp":1491409060654}
  5 Apr 18:17:40 - [info] [function:validations] [flow1 81687733.7e9788] Validations OK
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"7fe7c062.5373b","event":"node.function.send","msgid":"81687733.7e9788","timestamp":1491409060663}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"29d0fe16.a77122","event":"node.switch.receive","msgid":"81687733.7e9788","timestamp":1491409060663}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"29d0fe16.a77122","event":"node.switch.send","msgid":"81687733.7e9788","timestamp":1491409060664}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"266fb8b2.d3bc78","event":"node.function.receive","msgid":"81687733.7e9788","timestamp":1491409060665}
  5 Apr 18:17:40 - [info] [function:prepare_request_2_gitlab] [flow1 81687733.7e9788] GitLab server retrieved: https://gitlab.myserver.com
  5 Apr 18:17:40 - [info] [function:prepare_request_2_gitlab] [flow1 81687733.7e9788] URL for calling GitLab:
  https://gitlab.myserver.com/api/v3/projects/123/repository/files?file_path=...
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"266fb8b2.d3bc78","event":"node.function.send","msgid":"81687733.7e9788","timestamp":1491409060668}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"30f49e7b.f00732","event":"node.http request.receive","msgid":"81687733.7e9788","timestamp":1491409060669}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"266fb8b2.d3bc78","event":"node.function.duration","msgid":"81687733.7e9788","value":34.25,"timestamp":1491409060700}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"7fe7c062.5373b","event":"node.function.duration","msgid":"81687733.7e9788","value":39.82,"timestamp":1491409060701}
  5 Apr 18:17:40 - [metric] {"level":99,"nodeid":"4aa21f88.5424d","event":"node.function.duration","msgid":"81687733.7e9788","value":55.35,"timestamp":1491409060701}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"30f49e7b.f00732","event":"node.http request.duration.millis","msgid":"81687733.7e9788","value":"763.865","timestamp":1491409061433}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"30f49e7b.f00732","event":"node.http request.size.bytes","msgid":"81687733.7e9788","value":786,"timestamp":1491409061434}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"30f49e7b.f00732","event":"node.http request.send","msgid":"81687733.7e9788","timestamp":1491409061435}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"8cb13df8.2bdf8","event":"node.function.receive","msgid":"81687733.7e9788","timestamp":1491409061436}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"8cb13df8.2bdf8","event":"node.function.send","msgid":"81687733.7e9788","timestamp":1491409061436}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"982f8a3a.44e808","event":"node.function.receive","msgid":"81687733.7e9788","timestamp":1491409061437}
  5 Apr 18:17:41 - [info] [function:Base64] ewogICJkYXRvMSI6ICJ2YWxvcjEiLAogICJkYXRvMiI6ICJ2YWxvcjIiICAKfQo=
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"982f8a3a.44e808","event":"node.function.send","msgid":"81687733.7e9788","timestamp":1491409061440}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"dda129a5.c079c8","event":"node.http response.receive","msgid":"81687733.7e9788","timestamp":1491409061441}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"fbe50847.a50258","event":"node.http in.response.time.millis","msgid":"81687733.7e9788","value":"803.156","timestamp":1491409061447}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"fbe50847.a50258","event":"node.http in.response.content-length.bytes","msgid":"81687733.7e9788","value":"60","timestamp":1491409061448}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"982f8a3a.44e808","event":"node.function.duration","msgid":"81687733.7e9788","value":13.29,"timestamp":1491409061451}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"8cb13df8.2bdf8","event":"node.function.duration","msgid":"81687733.7e9788","value":15.6,"timestamp":1491409061452}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"404be498.cbc77c","event":"node.http request.duration.millis","msgid":"1a5f4041.e5a0c","value":"885.579","timestamp":1491409061485}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"404be498.cbc77c","event":"node.http request.size.bytes","msgid":"1a5f4041.e5a0c","value":492,"timestamp":1491409061491}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"404be498.cbc77c","event":"node.http request.send","msgid":"1a5f4041.e5a0c","timestamp":1491409061493}
  5 Apr 18:17:41 - [metric] {"level":99,"nodeid":"f78329d7.a270d8","event":"node.delay.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409061495}
  5 Apr 18:17:46 - [metric] {"level":99,"event":"runtime.memory.rss","value":104001536,"timestamp":1491409066252}
  5 Apr 18:17:46 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409066253}
  5 Apr 18:17:46 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":55347176,"timestamp":1491409066254}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f78329d7.a270d8","event":"node.delay.send","msgid":"1a5f4041.e5a0c","timestamp":1491409071498}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"408b745e.9f3f2c","event":"node.function.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409071498}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"408b745e.9f3f2c","event":"node.function.send","msgid":"1a5f4041.e5a0c","timestamp":1491409071505}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f259e413.5ae2f8","event":"node.switch.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409071505}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f259e413.5ae2f8","event":"node.switch.send","msgid":"1a5f4041.e5a0c","timestamp":1491409071506}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f4d72980.fc5ef8","event":"node.function.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409071506}
  5 Apr 18:17:51 - [info] [function:prepare_another_call] [flow2 1a5f4041.e5a0c] URL: http://localhost:1880/gitlab_interface/file?query=string2
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f4d72980.fc5ef8","event":"node.function.send","msgid":"1a5f4041.e5a0c","timestamp":1491409071508}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"79b169c0.1f8908","event":"node.http request.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409071508}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"f4d72980.fc5ef8","event":"node.function.duration","msgid":"1a5f4041.e5a0c","value":7.91,"timestamp":1491409071515}
  5 Apr 18:17:51 - [metric] {"level":99,"nodeid":"408b745e.9f3f2c","event":"node.function.duration","msgid":"1a5f4041.e5a0c","value":11.38,"timestamp":1491409071516}
  5 Apr 18:18:01 - [metric] {"level":99,"event":"runtime.memory.rss","value":104493056,"timestamp":1491409081255}
  5 Apr 18:18:01 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409081256}
  5 Apr 18:18:01 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56854872,"timestamp":1491409081256}
  5 Apr 18:18:16 - [metric] {"level":99,"event":"runtime.memory.rss","value":104493056,"timestamp":1491409096258}
  5 Apr 18:18:16 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409096259}
  5 Apr 18:18:16 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56866328,"timestamp":1491409096261}
  5 Apr 18:18:31 - [metric] {"level":99,"event":"runtime.memory.rss","value":104497152,"timestamp":1491409111266}
  5 Apr 18:18:31 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409111270}
  5 Apr 18:18:31 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56881696,"timestamp":1491409111274}
  5 Apr 18:18:46 - [metric] {"level":99,"event":"runtime.memory.rss","value":104525824,"timestamp":1491409126276}
  5 Apr 18:18:46 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409126277}
  5 Apr 18:18:46 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56954688,"timestamp":1491409126277}
  5 Apr 18:19:01 - [metric] {"level":99,"event":"runtime.memory.rss","value":104529920,"timestamp":1491409141279}
  5 Apr 18:19:01 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409141280}
  5 Apr 18:19:01 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56967392,"timestamp":1491409141281}
  5 Apr 18:19:16 - [metric] {"level":99,"event":"runtime.memory.rss","value":104529920,"timestamp":1491409156283}
  5 Apr 18:19:16 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409156284}
  5 Apr 18:19:16 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56979184,"timestamp":1491409156285}
  5 Apr 18:19:31 - [metric] {"level":99,"event":"runtime.memory.rss","value":104529920,"timestamp":1491409171290}
  5 Apr 18:19:31 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409171291}
  5 Apr 18:19:31 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":56990832,"timestamp":1491409171292}
  5 Apr 18:19:46 - [metric] {"level":99,"event":"runtime.memory.rss","value":104529920,"timestamp":1491409186294}
  5 Apr 18:19:46 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409186296}
  5 Apr 18:19:46 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":57021800,"timestamp":1491409186296}
  5 Apr 18:19:51 - [error] [http request:get_file] no response from server
  5 Apr 18:19:51 - [error] [http request:get_file] Error: socket hang up
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"79b169c0.1f8908","event":"node.http request.send","msgid":"1a5f4041.e5a0c","timestamp":1491409191542}
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"5c0d3d14.99fc94","event":"node.function.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409191543}
  5 Apr 18:19:51 - [warn] [function:prepare_output] [flow2 1a5f4041.e5a0c] Error retrieving the data from the storage
  Error: socket hang up : http://localhost:1880/gitlab_interface/file?query=string2
  5 Apr 18:19:51 - [warn] [function:init] [flow2 1a5f4041.e5a0c] Let's raise an error: ECONNRESET | Error retrieving the data from the storage
  5 Apr 18:19:51 - [info] [function:init] [flow2 1a5f4041.e5a0c] Error raised: ECONNRESET | Error retrieving the data from the storage
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"5c0d3d14.99fc94","event":"node.function.send","msgid":"1a5f4041.e5a0c","timestamp":1491409191549}
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"54690181.c294f","event":"node.http response.receive","msgid":"1a5f4041.e5a0c","timestamp":1491409191550}
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"eb5384b9.2266c8","event":"node.http in.response.time.millis","msgid":"1a5f4041.e5a0c","value":"130973.155","timestamp":1491409191554}
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"eb5384b9.2266c8","event":"node.http in.response.content-length.bytes","msgid":"1a5f4041.e5a0c","value":"105","timestamp":1491409191578}
  5 Apr 18:19:51 - [metric] {"level":99,"nodeid":"5c0d3d14.99fc94","event":"node.function.duration","msgid":"1a5f4041.e5a0c","value":35.34,"timestamp":1491409191580}
  Error: request aborted
      at IncomingMessage.onAborted (...\node-red-0.16.2\node_modules\body-parser\node_modules\raw-body\index.js:269:10)
      at emitNone (events.js:67:13)
      at IncomingMessage.emit (events.js:166:7)
      at abortIncoming (_http_server.js:280:11)
      at Socket.serverSocketCloseListener (_http_server.js:293:5)
      at emitOne (events.js:82:20)
      at Socket.emit (events.js:169:7)
      at TCP._onclose (net.js:477:12)
  5 Apr 18:20:01 - [metric] {"level":99,"event":"runtime.memory.rss","value":104878080,"timestamp":1491409201297}
  5 Apr 18:20:01 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":84781392,"timestamp":1491409201297}
  5 Apr 18:20:01 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":57427712,"timestamp":1491409201298}
  5 Apr 18:20:02 - [info] Stopping flows
  </code></pre>