node-red-docker icon indicating copy to clipboard operation
node-red-docker copied to clipboard

Node-RED loses connection with GPIOD after two “deploys” (frequent docker restart necessary) :(

Open DIYtechie opened this issue 5 years ago • 17 comments

What are the steps to reproduce?

Run node-red in the official docker container.

Verify that the gpiod nodes have connection to the gpiod (daemon). Skærmbillede 2020-02-09 kl  23 14 03 Check that gpio input node actually works (e.g. use a simple switch to connect pin 5 to ground and see "OK" changing to 1 or 0).

Skærmbillede 2020-02-10 kl  20 30 32

Move some nodes and click “Deploy”. Do it again.

Check that gpio input node still works (in my setup it stoppes working). The gpiod node still states "OK" which indicates the gpio daemon is running. Running ps aux confirms this. Skærmbillede 2020-02-10 kl  19 00 17

HOWEVER -connecting a pin to ground no longer makes the node change state.

restart the docker container - now it works again, but only until you click deploy 2 times again. Then a docker restart is needed again :(

Please tell us about your environment:

Hardware: Raspberry Pi 3B+.

  • [x] Node-RED version: 1.0.3
  • [ ] Node.js version: latest?
  • [ ] npm version: latest?
  • [x] Platform/OS: latest docker image. host os: latest Raspian Buster
  • [x] Browser: google chrome (not a browser issue).
  • [x] pigiod is latest version: Skærmbillede 2020-02-09 kl  23 38 54

DIYtechie avatar Feb 09 '20 23:02 DIYtechie

This issue remains, and more testing confirms that Node-RED loses connection to GPIOD after the second "Deploy".

Frustrating issue these days where I create a lot of new flows and therefore have to restart the container several times a day.

DIYtechie avatar Apr 03 '20 16:04 DIYtechie

Amy news on this issue? Still a PITA having to restart Node-RED container everytime I make a few changes in Node-RED.

DIYtechie avatar Aug 14 '20 17:08 DIYtechie

Hello, is it possible to enable the trace mode of the node-red logging and see what happening in the logs ? More informations on the setting file: https://nodered.org/docs/user-guide/runtime/settings-file and about some parameters: https://nodered.org/docs/user-guide/runtime/configuration Also have you been able to check if this error is only happening in the docker version and not the standalone version directly on raspbian ?

Ekristoffe avatar Aug 20 '20 00:08 Ekristoffe

Try this (my example uses vi but you can use the text editor of your choice):

$ cd ~/IOTstack
$ vi volumes/nodered/data/settings.js

Find this chunk of text:

logging: {
        // Only console logging is currently supported
        console: {
            // Level of logging to be recorded. Options are:
            // fatal - only those errors which make the application unusable should be recorded
            // error - record errors which are deemed fatal for a particular request + fatal errors
            // warn - record problems which are non fatal + errors + fatal errors
            // info - record information about the general running of the application + warn + error + fatal errors
            // debug - record information which is more verbose than info + info + warn + error + fatal errors
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            // off - turn off all logging (doesn't affect metrics or audit)
            level: "info",
            // Whether or not to include metric events in the log output
            metrics: false,
            // Whether or not to include audit events in the log output
            audit: false
        }
    },

Change level from "info" to "trace", the other options to true if you thing those would be useful, and save the file. Then:

$ docker-compose restart nodered
$ docker logs -f nodered

The restart causes NodeRed to pay attention to the settings.js change.

The logs command is like a tail -f for watching any other kind of log.

Control-C to abort and I'm sure you can work out how to undo the change.

Paraphraser avatar Aug 20 '20 01:08 Paraphraser

Thanks for your suggestions 🙏🏻 Will try them out as soon as possible. Probably in the weekend.

DIYtechie avatar Aug 20 '20 05:08 DIYtechie

I tried the above and now have a huge logfile. What should I look for and what should I post here for you to be able to help debugging? As mentioned, everything works right after a docker restart nodered. The issue arises after the second deploy efter a restart.

DIYtechie avatar Aug 22 '20 08:08 DIYtechie

how huge is the file ? Could you put it as attachement (check before there is no credencial or confidential information inside)

Ekristoffe avatar Aug 24 '20 10:08 Ekristoffe

how huge is the file ? Could you put it as attachement (check before there is no credencial or confidential information inside)

It's a 93 MB pure text file, but I am worried that it contains confinendial information (searching for "PSK" returned more than 16,000 hits). What am I looking for? perhaps I can cut out the relevant sections?

DIYtechie avatar Aug 31 '20 16:08 DIYtechie

As it I will say any error message. Plus if you can try to split your file from the first boot and each reload and see what are the differences.

Ekristoffe avatar Sep 01 '20 00:09 Ekristoffe

Amy news on this issue? Still a PITA having to restart Node-RED container everytime I make a few changes in Node-RED.

I am not investigating this issue and it's not a best-way-solution, but you might want consider a second NR container which does the GPIO interaction and another (probably your existing container) which does the rest of all your flows.

pi gpio <-> node-red-gpio-container <-> mqtt <-> node-red-main-container

Using the concept of "Separation of concerns" and to avoid the connection loss after each "Deployment" of your flows.

RaymondMouthaan avatar Sep 08 '20 22:09 RaymondMouthaan

Thanks for sharing this idea for a workaround. 👍🏻Hadn’t thought of that. I still would like this issue solved, but not sure how to get the relevant data from the log file.

DIYtechie avatar Sep 09 '20 19:09 DIYtechie

Is this being fixed at any point soon? Really frustrating when node just does not work as it should after a deploy.

Nodi-Rubrum avatar Feb 15 '21 04:02 Nodi-Rubrum

by whom ? More than happy to accept help any assistance from someone who can re-create the problem and help identify the actual issue.

dceejay avatar Feb 15 '21 09:02 dceejay

A workaround in some cases is to only deploy the changed nodes and not the whole flow or all flows. Now that I’m working on other flows this really saves me from a lot of frustration.

DIYtechie avatar Feb 15 '21 09:02 DIYtechie

In the underlying library `node_modules/js-pigpio/index.js' I see the close method

pigpio.prototype.close = function() {
    "use strict";
    this.sl.s.end();
};

maybe try changing that to this.sl.s.destroy(); so it really closes the connection rather than half-closes it... feedback please

dceejay avatar Feb 15 '21 09:02 dceejay