0

在我的流程中,我在 Node-red 中遇到了一个问题,我对我的 node-red 中的另一个服务有几个 http 请求。据我所见,当我对同一个域进行第二次调用时总是会出现错误(即:localhost,尽管它可能与另一个域有关)

总结:我有2个不同的流程:

  • 一个作为 gitlab 接口,用于从那里检索文件。所以我从这里调用 gitlab 服务器(流程 1
  • 另一个我的应用程序,需要检索 2 个不同的文件。从这个流程中,我调用了 2 次到上一个流程(Flow 2

所以,一旦我的第二个流程启动,在一些 JavaScript 和切换节点之后,我第一次调用到第一个流程,它调用 gitlab。这工作得很好第二个流程继续并在另一个 JavaScript 节点之后再次调用第一个流程,似乎流程被冻结并且没有任何反应,2 分钟后我收到此错误:

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)

你知道可能是什么错误吗?

我在 Internet 上搜索了有关 nodejs 中的此错误,例如:

Nodejs Socket hang up & ECONNRESET - 从 Meteor 到 Node js 服务器的 HTTP post 请求 Node.js POST 导致 [Error: socket hang up] code: 'ECONNRESET' Node js ECONNRESET 我一直在本地测试其中一些可能的解决方案(修改library follow-redirects和节点21-httprequest.js)但没有任何成功,所以我不知道为什么会发生这个错误

我也尝试设置延迟,以确保这不是时间问题

我正在使用 node-red v0.16.2 和 nodejs v4.4.3

预先感谢,问候。

PS:我已经使用指标进行了测试:

λ 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
4

1 回答 1

1

When you have two HTTP Request nodes in the same flow, you must ensure you delete the msg.headers property returned by the first node before passing the msg to the second node. This is because the headers from the first node are the response headers, and by passing them to the second node you are asking that node to use those headers in making its request.

You should also make use of the Debug node to see where a flow is getting to; your second call to the gitlab_interface flow is hanging - adding Debug nodes after each node in that flow would tell you where the flow was getting to.

于 2017-04-05T19:34:00.167 回答