Node-RED Stopped Running but not Crashed

Hello, I run Node-RED on a Windows Server 2019, the node-red stopped running, the terminal not shown any crashes but when I access the node-red from browser, it won't load, and my programs that use node-red also not running, then I click the terminal and click arrow or any key, it will continue the process, the interval is quite random,

I run multiple flows on node-red, like a scheduler to run a php script weekly, retrieving data from an API then insert to mysql, subscribe to mqtt and then insert to mysql, etc

I am not sure about what happen because it didn't crash, it just stop like hanging, when I click it, it run again as if it pauses then resume when I click it

I am using v 4.0.2

if there is anything that I should check and provide to find the root cause please let me know, and thanks in advance

(I'll byte)

Stop Node-Red (From the CMD thing)

node-red-stop

Then run the command
node-red

Copy/paste the text output to the CLI so others can see what is happening.

When pasting the text, BEFORE YOU PASTE IT:

press the key just to the left of the 1 key (top row).
It sort of looks like ' and has the~ above it.
THREE TIMES
paste the code
On a new line, repeat above.

(OR)

Press the button at the top of this window that looks like </> and paste the code where it says.

type or paste code here

(as shown)

Thank you, I need to wait until the node-red stopped,

what you meant is like this right

type or paste code here

noted

I tried to use node-red-stop, but it said

'node-red-stop' is not recognized as an internal or external command,
operable program or batch file.

tried on the same terminal but it won't let me type anything so I run it from another terminal but that is what happen, should I just do the usual close the terminal window?

Node red is running on Windows, not Linux.

It sounds like you might have a runaway loop, perhaps involving the mqtt broker.

For example a flow subscribes to an mqtt topic and then posts to the same topic.

When doubt, put an rbe node in to break the loop and set it to only pass messages that are different than the previous one. Seems node-red designers ran into this a lot with mqtt in very early versions as you still see remnants of what appears to have been be an attempt at automatic loop breaking with msg._topic in debug nodes when you view the complete message object.

1 Like

I don't see why simply clicking a key in the terminal window would fix it in that case.

@TotallyInformation I vaguely remember a similar post some time ago being answered by yourself, but perhaps I am mistaken.

Edit: Something about the process running in a terminal window being paused under some circumstances.

I barely remember yesterday, let alone a post from who-knows when! :smiley:

But you may be right. We don't know what the OP's flow actually does, so hard to analyse. But if there is something that is running a process on the server, especially maybe a PowerShell or cmd exec, it could be waiting for an input.

Is an exec node in use? If so, try setting its timeout value. Though obviously, that isn't a fix.

I too have trouble remembering details, but something seems to have triggered a memory here. I thought it was more general than the flow waiting for input (though certainly it could be that), it was more like a problem that long running applications running in a terminal in Windows could get accidentally paused somehow.

Quite likely I am completely mistaken though.

@ajisindhu9 I searched for
long running application in Windows terminal pausing
and it seems that others have seen such things happen. Possibly due to clicking in the window title bar or in the window. Something to do with it thinking you are selecting text.

doesn't clicking in a window suspend it (certainly stops scrolling etc) ?
E.G. https://superuser.com/questions/1442941/windows-10-console-stops-running-if-i-click-in-the-console-window
If the OP is just running the node-red command in a window (not as a service) then it would be easy to click on the window to bring it to the front and maybe accidentally pass it at the same time.... maybe...

although I was shot down in flames,

Has node-red been stopped and restarted again to see the start log?

(Just asking)

Because that would show a runaway event happening - yes?

Hmm, well I run my dev instance under PM2 with the command window showing the live logs permanently. It certainly doesn't do that in that case.

Maybe try running under PM2 if currently running manually.

Dramatic! No, Colin was just saying that was less likely.

I'm not sure it would - unless you could see something else happening or whatever was looping was outputting to the log.

Ok... Sorry. Had just gotten up and maybe not thinking too clearly.

But I originally replied as I saw a few people had looked and no reply.

I only wanted to at least get a bit more information than in the O/P.
(I think that part did work though.) :wink:

2 Likes

wow, I am surprised by a lot of comments and helps,


I do have flow like this, I don't really remember why I put this, but I think it is related to my device got false positive from node-red, I admit that it happen because I don't really understand how mqtt and its qos works

[
    {
        "id": "0aeb209feaada50c",
        "type": "mqtt in",
        "z": "b89019e2f6e43ba2",
        "name": "",
        "topic": "resURL",
        "qos": "1",
        "datatype": "auto-detect",
        "broker": "489be411582992b5",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 70,
        "y": 600,
        "wires": [
            [
                "51f435c5afc961a1",
                "8fe535d9a6928f0c"
            ]
        ]
    },
    {
        "id": "51f435c5afc961a1",
        "type": "function",
        "z": "b89019e2f6e43ba2",
        "name": "function 104",
        "func": "var mesej = msg.payload\n\nif(mesej == \"\"){\n    msg.payload = \"\"\n    return msg;\n} else if (mesej == \"Data Sudah Terupdate   \"){\n    flow.set(\"process\", 0)\n    flow.set(\"statResURL\", 1)\n}else{\n    flow.set(\"statResURL\", 1)\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 250,
        "y": 600,
        "wires": [
            [
                "2ceef4b134da1581"
            ]
        ]
    },
    {
        "id": "e69e7a9244ca6662",
        "type": "mqtt out",
        "z": "b89019e2f6e43ba2",
        "name": "",
        "topic": "resURL",
        "qos": "1",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "489be411582992b5",
        "x": 820,
        "y": 600,
        "wires": []
    },
    {
        "id": "2ceef4b134da1581",
        "type": "delay",
        "z": "b89019e2f6e43ba2",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 420,
        "y": 600,
        "wires": [
            [
                "d754b67d59b10ace"
            ]
        ]
    },
    {
        "id": "d754b67d59b10ace",
        "type": "function",
        "z": "b89019e2f6e43ba2",
        "name": "function 122",
        "func": "var pesan = msg.payload\nvar stat = flow.get(\"statResURL\") | 0\nif (stat == 1) {\n    flow.set(\"statResURL\", 0)\n} else {\n    msg.payload = pesan\n    return msg;\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 590,
        "y": 600,
        "wires": [
            [
                "e69e7a9244ca6662"
            ]
        ]
    },
    {
        "id": "8fe535d9a6928f0c",
        "type": "switch",
        "z": "b89019e2f6e43ba2",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Data Sudah Terupdate    ",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 240,
        "y": 720,
        "wires": [
            [
                "51ffbcf9ef3464d6"
            ]
        ]
    },
    {
        "id": "51ffbcf9ef3464d6",
        "type": "change",
        "z": "b89019e2f6e43ba2",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "process",
                "pt": "flow",
                "to": "0",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 720,
        "wires": [
            []
        ]
    },
    {
        "id": "489be411582992b5",
        "type": "mqtt-broker",
        "name": "Control Room",
        "broker": "172.16.16.253",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

I know but happen is the opposite, the window suspend, and when I click, it run again, and I just know that node red can be run as a service !

if that is the case, should I just run node-red as service ?

now, should I use PM2 or run node-red as a service ?

You could also run PM2 as a service if you wanted to.

In reality, I suggested it because it would run under a slightly different context and might make a difference, might reveal something.

In truth, if you are running this service on a Windows Server, I would generally assume that it should be treated as a production service.

As such, there are a bunch of things you should be doing. For example, I would never run Node-RED directly on a production Windows server, I would use the standard iisnode so that IIS is acting as the proxy and iisnode takes care of ensuring that the Node-RED service is always running. This means that the Node-RED web endpoints can be (and should be) protected using AD and linked to AD accounts for authentication and authorisation.

yes I am running node red on a windows server, well there are a lot of things I should learn, thank you so much