No output from node - Why?

I am not sure about the reasons for this issue. I had some error in the flow caused by a node which was not installed. I resolved that and restarted nodered.
Now, all my flows which have been working without issues for months are not giving any output.
I do not see errors of any type. The exec node has a PID. The script is working. I don't know what to look for. If I create a simple inject/debug node, it is working but all my proven working nodes do not give output.
Here is one of the nodes not giving output (just a temperature probe).

[{"id":"f20693fd.b834c","type":"inject","z":"4e4990f3.d4ada","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":540,"wires":[["af021ac0.286e18"]]},{"id":"1eeb94bf.26d04b","type":"debug","z":"4e4990f3.d4ada","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":500,"wires":[]},{"id":"af021ac0.286e18","type":"exec","z":"4e4990f3.d4ada","command":" bash /home/pi/Develop/Temp/Temperature.sh","addpay":"","append":"","useSpawn":"true","timer":"","oldrc":false,"name":"Command Temperature","x":370,"y":540,"wires":[["2473ff7.e3f4d"],[],[]]},{"id":"563647d0.68ebd8","type":"influxdb out","z":"4e4990f3.d4ada","influxdb":"b87cafc6.11924","name":"Temp-Influx","measurement":"temperature","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":750,"y":580,"wires":[]},{"id":"2473ff7.e3f4d","type":"function","z":"4e4990f3.d4ada","name":"","func":"var t=msg.payload;\nif(t!==\"\")\n{\nk=t.split(':');\nfor (i = 0; i < k.length; i++)\n{\n    k[i]=parseFloat(k[i]);\n}\nmsg.topic=\"Temperature\";\n\tif(k[0]&&k[1])\n\t\t{\n\t\tmsg.payload={\"DegC\":k[0],\"DegF\":k[1]};\n\t\treturn msg;\n\n    }\n}\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":540,"wires":[["563647d0.68ebd8","1eeb94bf.26d04b"]]},{"id":"b87cafc6.11924","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"datastorage","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true}]

The exec node has a PID. The script is working. I don't know why there is no output? Any hint?

Update
could this be the problem?

pi@raspberrypi:~ $ sudo apt-get upgrade nodered
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libnode64 : Conflicts: nodejs-legacy
 nodered : Depends: npm (>= 5.8)
E: Broken packages

What version of Node-RED are you using?

How did you install Node-RED originally? Did you use our install script? If so, then you do not use apt-get to update anything to do with Node-RED.

It was installed by default with the Raspberry os.
apt-get...... noted, thanks. I don't know why I used the apt-get!
I update it with:

sudo npm install -g --unsafe-perm node-red

The version installed is V 1.3.5, but the problem is not solved. Still no output. Help!

Dont call the command in a shell script... thats what the problem is.

execute the command in the exec node

Thanks but I don't think that's the problem. Has been working for months with the shell scripts.However I tried, same issue.
I have left it running overnight and I noted something quite strange.
The Python script output is timed every 30 seconds.

while True:
    try:
                 
          c,f=read_temp()
          a="{:.3f}:{:.3f}".format(c,f)
          print(a)
          
          time.sleep(30)

Looks like the stream of the script is stuck somewhere and it comes all together in one big batch. Look at the picture. The first output is correct (object with Deg C and Deg F), the second one is an error (string) which it gets filtered out by the function. Then it stop for hours until it happens again. I suspect my Nodered is broken.

[{"id":"f20693fd.b834c","type":"inject","z":"4e4990f3.d4ada","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":480,"wires":[["af021ac0.286e18"]]},{"id":"1eeb94bf.26d04b","type":"debug","z":"4e4990f3.d4ada","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":480,"wires":[]},{"id":"af021ac0.286e18","type":"exec","z":"4e4990f3.d4ada","command":" bash /home/pi/Develop/Temp/Temperature.sh","addpay":"","append":"","useSpawn":"true","timer":"","oldrc":false,"name":"Command Temperature","x":370,"y":540,"wires":[["2473ff7.e3f4d","1eeb94bf.26d04b"],[],[]]},{"id":"563647d0.68ebd8","type":"influxdb out","z":"4e4990f3.d4ada","influxdb":"b87cafc6.11924","name":"Temp-Influx","measurement":"temperature","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":750,"y":580,"wires":[]},{"id":"2473ff7.e3f4d","type":"function","z":"4e4990f3.d4ada","name":"","func":"var t=msg.payload;\nif(t!==\"\")\n{\nk=t.split(':');\nfor (i = 0; i < k.length; i++)\n{\n    k[i]=parseFloat(k[i]);\n}\nmsg.topic=\"Temperature\";\n\tif(k[0]&&k[1])\n\t\t{\n\t\tmsg.payload={\"DegC\":k[0],\"DegF\":k[1]};\n\t\treturn msg;\n\n    }\n}\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":560,"wires":[["563647d0.68ebd8","1eeb94bf.26d04b"]]},{"id":"b87cafc6.11924","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"datastorage","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true}]

I may have to uninstall red node completely and reinstall it. Before I do that, any other hint? Thanks

How exactly are you calling the python from exec ? Are you using the -u parameter on python to ensure it is unbuffered ?

Until now I use to call a bash and has been working for the last six months:

bash /home/pi/Develop/Temp/Temperature.sh

After the advice from Leftymuler above, I have tried to call directly the python script:

python /home/pi/Develop/Temp/Temperature.py

however I do not see any change. It is still not working. As I said it worked for months without issues. I tend to think that something is broken somewhere because there were no changes in the code neither in the flow when things started going wrong.

Try adding -u to the python call

1 Like

Bingo!
Looks like it is working.
I do not understand why. Thanks a million for this.
Could you please elaborate on this? I am eager to understand what could have happened.

As I hinted, by default python will buffer its output (and release it now and again when the buffer is full or flushed) . the -u stops it buffering.

1 Like

Sorry to bother you again on this question. Can you point me to some reference for the -u. I am battling find it in the documentation.

From man python:

$ man python
PYTHON(1)                                                            General Commands Manual                                                            PYTHON(1)

NAME
       python - an interpreted, interactive, object-oriented programming language
[snip]
SYNOPSIS
       python [ -B ] [ -d ] [ -E ] [ -h ] [ -i ] [ -m module-name ]
              [ -O ] [ -OO ] [ -R ] [ -Q argument ] [ -s ] [ -S ] [ -t ] [ -u ]
              [ -v ] [ -V ] [ -W argument ] [ -x ] [ -3 ] [ -?  ]
              [ -c command | script | - ] [ arguments ]
[snip]
COMMAND LINE OPTIONS

       -u     Force stdin, stdout and stderr to be totally unbuffered.  On systems where it matters, also put stdin, stdout and stderr in binary mode.  Note that
              there  is  internal  buffering in xreadlines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this op‐
              tion.  To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop.

Thank you!
Obviously I am not a coder. Just hobby but very curious.
Thanks

Most commands and some system files have man pages.
eg man wpa_supplicant, man wpa_supplicant.conf
The contents tend to be terse and cryptic but they always list command line options and sometimes include examples of usage.
man output is piped through less (I think) so you have to type q or CTRL C to get back to the dollar prompt.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.