hassio-addons / addon-node-red

Node-RED - Home Assistant Community Add-ons
https://addons.community
MIT License
536 stars 125 forks source link

No Home Assistant connection after Node-RED restart #458

Closed lightmaster closed 4 years ago

lightmaster commented 4 years ago

Problem/Motivation

After restarting Node-RED from supervisor, Node-RED is no longer connecting to Home assistant and is throwing an error about an "Invalid access token or password"

Log
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 

-----------------------------------------------------------
 Hass.io Add-on: Node-RED
 Flow-based programming for the Internet of Things
-----------------------------------------------------------
 Add-on version: 6.0.4
 You are running the latest version of this add-on.
 System: null  (amd64 / qemux86-64)
 Home Assistant version: 0.105.5
 Supervisor version: 201
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] node-red.sh: executing... 
[12:47:57] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[12:47:58] INFO: Password is NOT in the Have I Been Pwned database! Nice!
patching file nodes/ui_base.html
Hunk #1 succeeded at 1243 (offset 712 lines).
npm WARN babel-loader@7.1.5 requires a peer of babel-core@6 but none is installed. You must install peer dependencies yourself.
npm WARN babel-loader@7.1.5 requires a peer of webpack@2 || 3 || 4 but none is installed. You must install peer dependencies yourself.

audited 17226 packages in 43.523s

27 packages are looking for funding
  run `npm fund` for details

found 5 vulnerabilities (2 low, 1 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details
[cont-init.d] node-red.sh: exited 0.
[cont-init.d] user.sh: executing... 
[12:48:48] INFO: Starting installation of custom NPM/Node-RED packages...
+ node-red-contrib-theme-midnight-red@1.0.29
updated 1 package and audited 3856 packages in 19.616s

19 packages are looking for funding
  run `npm fund` for details

found 2 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[12:49:12] INFO: Starting Node-RED...
[services.d] done.

> hassio-addon-node-red@ start /opt
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"

23 Feb 12:49:14 - [info] 

Welcome to Node-RED
===================

23 Feb 12:49:14 - [info] Node-RED version: v1.0.3
23 Feb 12:49:14 - [info] Node.js  version: v12.14.0
23 Feb 12:49:14 - [info] Linux 4.4.59+ x64 LE
23 Feb 12:49:15 - [info] Loading palette nodes
Initializing chat-platform lib, you should see this only once
Running at: /config/node-red/node_modules/chat-platform Version: 1.0.11

Sun, 23 Feb 2020 17:49:25 GMT node-telegram-bot-api deprecated Automatic enabling of cancellation of promises is deprecated.
In the future, you will have to enable it yourself.
See https://github.com/yagop/node-telegram-bot-api/issues/319. at internal/modules/cjs/loader.js:959:30
23 Feb 12:49:32 - [info] RedBot version: 0.18.12 (node-red-contrib-chatbot)
Compiling dictionary
23 Feb 12:49:56 - [info] Dashboard version 2.19.4 started at /endpoint/ui
Traceback (most recent call last):
  File "/opt/node_modules/node-red-node-pi-gpio/testgpio.py", line 4, in <module>
    import RPi.GPIO as GPIO
  File "/usr/lib/python2.7/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
23 Feb 12:50:02 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
23 Feb 12:50:02 - [info] Settings file  : /etc/node-red/config.js
23 Feb 12:50:02 - [info] Context store  : 'default' [module=memory]
23 Feb 12:50:02 - [info] User directory : /config/node-red/
23 Feb 12:50:02 - [warn] Projects disabled : editorTheme.projects.enabled=false
23 Feb 12:50:02 - [info] Flows file     : /config/node-red/flows.json
23 Feb 12:50:02 - [info] Server now running at http://127.0.0.1:46836/
23 Feb 12:50:02 - [info] Starting flows
Telegram Bot Home Assistant Telegram will be launched, environment is development
No context provider specified for chatbot Home Assistant Telegram. Defaulting to "memory"
23 Feb 12:50:02 - [info] Started flows

------ WebHooks for TELEGRAM----------------
http://localhost:46836/redbot/telegram/test/
http://localhost:46836/redbot/telegram/

[12:50:02] INFO: Starting NGinx...
23 Feb 12:50:02 - [info] [server:Home Assistant] WebSocket Connecting http://supervisor/core
23 Feb 12:50:02 - [error] [server:Home Assistant] Error: Invalid access token or password for websocket
nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)

Expected behavior

(What you expected to happen)

Actual behavior

(What actually happened)

Steps to reproduce

(How can someone else make/see it happen)

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

lightmaster commented 4 years ago

Figured out why it couldn't connect. The "I use the Home Assistant Add-on" checkbox was unchecked in the configuration node, however I have never messed with that node and have no idea how it got unchecked.

sinclairpaul commented 4 years ago

It sounds to me you are manually updating the Home Assistant node on the palette, as this change is not in the add on version yet. By doing that you may run into these kinds of issues.

mathieu-mp commented 4 years ago

@sinclairpaul I met the exact same issue, and I hadn't messed with this option before. Isn't it a real bug that other might encounter ? And how to solve so that it doesn't mess with future updates ?

Wictorssons commented 4 years ago

@sinclairpaul I run Hass.io and updated the Node-Red addon like I always do, via the Add-ons page and also got the same problem. 20-02-24 19:55:22 INFO (MainThread) [hassio.api.security] /dns/info access from a0d7b954_nodered 20-02-24 19:55:32 INFO (MainThread) [hassio.api.proxy] Home Assistant WebSocket API request initialize 20-02-24 19:55:32 WARNING (MainThread) [hassio.api.proxy] Unauthorized WebSocket access! Took a few hours until I also found that the "I use the Home Assistant Add-on" checkbox was unchecked. Like mathieu-mp, I have never touched this setting before, that I can remember.

sinclairpaul commented 4 years ago

The latest release should have automatically changed this for you, however will add something to the docs as a troubleshooting step. There is really nothing apart from that which can be done from the addon perspective (the challenge is around the changes to the node configuration).

addons-assistant[bot] commented 4 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.