Сокет зависает при выполнении нескольких http-запросов в моем потоке
У меня проблема с Node-red, когда в моем потоке у меня есть несколько http-запросов к другим сервисам на моем узле-red. Насколько я вижу, ошибка всегда возникает, когда я делаю второй вызов в тот же домен (то есть: localhost, хотя это может быть с другим доменом)
Как резюме: у меня есть 2 разных потока:
- Один как интерфейс gitlab для получения файлов оттуда. Итак, отсюда я звоню на сервер gitlab ( Поток 1)
- Еще одно мое приложение, которое должно получить 2 разных файла. Из этого потока я вызываю 2 раза к предыдущему потоку ( Поток 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)
У вас есть идея, в чем может быть ошибка?
Я искал в интернете об этой ошибке в nodejs, например:
Nodejs Socket зависает и ECONNRESET - HTTP-запрос поста от Meteor к серверу Node js Node.js POST вызывает [Ошибка: сокет зависания] код: 'ECONNRESET' Узел js ECONNRESET Я тестировал локально некоторые из этих возможных решений (модифицируя библиотека перенаправляет и узел 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
1 ответ
Когда у вас есть два HTTP Request
узлы в том же потоке, вы должны убедиться, что вы удалите msg.headers
свойство, возвращаемое первым узлом перед передачей сообщения второму узлу. Это потому что headers
от первого узла находятся заголовки ответа, и, передавая их второму узлу, вы просите этот узел использовать эти заголовки при выполнении своего запроса.
Вы также должны использовать узел Debug, чтобы увидеть, куда попадает поток; Ваш второй звонок в gitlab_interface
Поток зависает - добавление отладочных узлов после каждого узла в этом потоке сообщит вам, куда этот поток попал.