node-red / node-red-docker

Repository for all things Node-RED and Docker related
Apache License 2.0
469 stars 382 forks source link

unhealthy state since v3.0.0 #404

Closed Bond246 closed 5 months ago

Bond246 commented 5 months ago

Hello,

i'm usind Node-RED in Docker an most of the time in latest version. Since v3.0 i'm using the latest image for node.js 18 so my docker-run command is this:

docker run -d -p 1880:1880 -e TZ=Europe/Berlin -v Node-RED_data:/data --name Node-RED nodered/node-red:latest-18

And since i've upgrade to v3.0.0 (and now 3.1.3) with nodejs v18 i get in portainer only an unhealthy state.

{
  "Status": "unhealthy",
  "FailingStreak": 51,
  "Log": [
    {
      "Start": "2024-01-24T14:33:54.459224207+01:00",
      "End": "2024-01-24T14:33:54.5469603+01:00",
      "ExitCode": 1,
      "Output": ""
    },
    {
      "Start": "2024-01-24T14:34:24.548056809+01:00",
      "End": "2024-01-24T14:34:24.635938659+01:00",
      "ExitCode": 1,
      "Output": ""
    },
    {
      "Start": "2024-01-24T14:34:54.636353532+01:00",
      "End": "2024-01-24T14:34:54.725347842+01:00",
      "ExitCode": 1,
      "Output": ""
    },
    {
      "Start": "2024-01-24T14:35:24.726618603+01:00",
      "End": "2024-01-24T14:35:24.816215339+01:00",
      "ExitCode": 1,
      "Output": ""
    },
    {
      "Start": "2024-01-24T14:35:54.817300984+01:00",
      "End": "2024-01-24T14:35:54.906592866+01:00",
      "ExitCode": 1,
      "Output": ""
    }
  ]
}

My Node-RED Log looks like that:

24 Jan 14:45:24 - [info] 
Welcome to Node-RED
===================
24 Jan 14:45:24 - [info] Node-RED version: v3.1.3
24 Jan 14:45:24 - [info] Node.js  version: v18.19.0
24 Jan 14:45:24 - [info] Linux 5.15.0-91-generic x64 LE
24 Jan 14:45:24 - [info] Loading palette nodes
24 Jan 14:45:25 - [info] Dashboard version 3.6.2 started at /ui
24 Jan 14:45:25 - [info] Settings file  : /data/settings.js
24 Jan 14:45:25 - [info] Context store  : 'default' [module=localfilesystem]
24 Jan 14:45:25 - [info] User directory : /data
24 Jan 14:45:25 - [warn] Projects disabled : editorTheme.projects.enabled=false
24 Jan 14:45:25 - [info] Flows file     : /data/flows.json
24 Jan 14:45:25 - [info] Server now running at http://127.0.0.1:1880/
24 Jan 14:45:25 - [info] Starting flows
24 Jan 14:45:26 - [info] [ui_heater_controller:WZ control] Heater Constructor
24 Jan 14:45:26 - [info] [ui_heater_controller:Bad control] Heater Constructor
24 Jan 14:45:26 - [info] [ui_heater_controller:Küche control] Heater Constructor
24 Jan 14:45:26 - [info] Started flows
24 Jan 14:45:26 - [info] [mqtt-broker:ubuntu-home] Connected to broker: NodeRed@mqtt://mosquitto :1883
24 Jan 14:45:27 - [info] [deconz-server:ubuntu_deconz] WebSocket opened

And some basics in addition:

[ ] Platform/OS: Ubuntu 22.04.3 LTS

[ ] Browser: Firefox

Portainer Details: grafik

node-red.log

Thanks for helping!

Florian

hardillb commented 5 months ago

Can you run the following command on the host machine and supply the output please

curl -v http://localhost:1880/

Also have you enabled httpAdminAuth in the settings.js?

hardillb commented 5 months ago

And what is the output of docker ps? Does the container show as healthy in that list?

Bond246 commented 5 months ago

Hello hardillb,

curl-output:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!--
  Copyright OpenJS Foundation and other contributors, https://openjsf.org/

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<title>Node-RED</title>
<link rel="icon" type="image/png" href="favicon.ico">
<link rel="mask-icon" href="red&#x2F;images&#x2F;node-red-icon-black.svg" color="#8f0000">
<link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v=">
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v=">
<link rel="stylesheet" href="red/style.min.css?v=">
<link rel="stylesheet" href="vendor/monaco/style.css?v=">
</head>
<body spellcheck="false">
<div id="red-ui-editor"></div>
<script src="vendor/vendor.js?v="></script>
<script src="vendor&#x2F;monaco&#x2F;monaco-bootstrap.js?v="></script>
<script src="red&#x2F;red.min.js?v="></script>
<script src="red&#x2F;main.min.js?v="></script>

</body>
</html>

settings.js adminAuth:

adminAuth: {
        type: "credentials",
        users: [{
            username: "admin",
            password: "key",
            permissions: "*"
        }],
        default: {
        permissions: "read"
    }
    },

httpAdminAuth ist not defined in my settings.js.

docker ps output:

docker ps | grep Node-RED

710725be73f5   nodered/node-red:latest-18                   "./entrypoint.sh"         27 minutes ago   Up 27 minutes (unhealthy)      0.0.0.0:1880->1880/tcp, :::1880->1880/tcp
Node-RED
hardillb commented 5 months ago

Thanks, but I need the full output of the curl -v command please (I need the headers as well as the output)

Bond246 commented 5 months ago

hmm, i'm wondering why it hasn't been copied to my exported file. Sorry.

*   Trying 127.0.0.1:1880...
* Connected to localhost (127.0.0.1) port 1880 (#0)
> GET / HTTP/1.1
> Host: localhost:1880
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=utf-8
< Content-Length: 1670
< ETag: W/"686-xRT8RtOh8fuWOY7Y8PpX4OnwZro"
< Date: Wed, 24 Jan 2024 14:17:39 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!--
  Copyright OpenJS Foundation and other contributors, https://openjsf.org/

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<title>Node-RED</title>
<link rel="icon" type="image/png" href="favicon.ico">
<link rel="mask-icon" href="red&#x2F;images&#x2F;node-red-icon-black.svg" color="#8f0000">
<link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v=">
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v=">
<link rel="stylesheet" href="red/style.min.css?v=">
<link rel="stylesheet" href="vendor/monaco/style.css?v=">
</head>
<body spellcheck="false">
<div id="red-ui-editor"></div>
<script src="vendor/vendor.js?v="></script>
<script src="vendor&#x2F;monaco&#x2F;monaco-bootstrap.js?v="></script>
<script src="red&#x2F;red.min.js?v="></script>
<script src="red&#x2F;main.min.js?v="></script>

</body>
</html>
* Connection #0 to host localhost left intact
hardillb commented 5 months ago

Also can you try the following:

  1. run docker exec -it Node-RED /bin/bash
  2. at the shell run vi /healthcheck.js
  3. delete the // from before the console.log lines
  4. save and exit
  5. then run node /healthcheck.js

I wonder if this is a IPv6 thing in the healthcheck script.

Bond246 commented 5 months ago
~ docker exec -it -u root Node-RED /bin/bash

a5023417dca6:/usr/src/node-red# vi /healthcheck.js
a5023417dca6:/usr/src/node-red# vi /healthcheck.js
a5023417dca6:/usr/src/node-red# node /healthcheck.js
ERROR Error: connect ECONNREFUSED ::1:1880
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 1880
}
a5023417dca6:/usr/src/node-red#
hardillb commented 5 months ago

Yep, that's it

A quick fix is to edit that file again and replace localhost with 127.0.0.1

(you can comment the console.log out agian)

I'll update the script for the next release

Bond246 commented 5 months ago

That was fast :) It's heathy again now.

Big Thanks!