Blocking error blocking error

nodered 3.1.7, after a few days of functioning correctly nodered crashes and I have to restart it manually to make it work. here is the error log it writes :Unhandled rejection RequestError: Error: read ETIMEDOUT at new RequestError (/data/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/data/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/data/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/data/node_modules/request/request.js:185:22) at Request.emit (node:events:513:28) at Request.onRequestError (/data/node_modules/request/request.js:877:8) at ClientRequest.emit (node:events:513:28) at TLSSocket.socketErrorListener (node:_http_client:494:9) at TLSSocket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21)

what could this be due to? has anyone had this problem before

A node or function node using the package request is not correctly handling exceptions.

Are you making http requests from within a function node?

yes it is a sequence for querying the API of a site, for now it is disabled but I would like to restore it, I can't find the error even by trial and error it keeps giving an error after a few hours of operation. Sorry for replying now but the forum notification service is not working for me.

Add try .. catch blocks around the requests in the function node, that should catch the error.

1 Like

If you are doing async, use try...catch if you are using promises, add a .catch handler.

Better still, use the built in http-request node and it is all done for you.

1 Like

@colin,@steve,
I will now try to edit then write down what I have changed

Why are you not using the http node?

the node is this, basically it is an alert that reads api data on bybit, compares it to a minimum set by dashboard page, and if it is below the threshold it sends a voice alert with alexa.
flows.json (15,0 KB)
can't find the error in the http request :sweat:

For the future please see this post for details of the preferred method of posting flows - How to share code or flow json

Earlier you said that you were making http requests from within a function node, but the flow you posted is using an http request node. Are you saying that the http request node is generating the error that you posted at the start?

Yes, and I don't know what to think anymore.

That is unlikely. The error in the first post comes from /data/node_modules/request/request.js (AKA request lib) whereas Node-RED HTTP-Request node uses GOT lib)

however, by disabling the node mentioned above ,nodered does not crash and works regularly

yes, probably because of what follows - the alexa node. If the request is disabled, the next nodes in the chain are NOT triggered!

so it would mean that the 'error is not to be found in the flow that I reported above , but in the others that I have ?

Disconnect the wire to the alexa node and see what happens.
If it still crashes then disconnect the wire from the http request node and try again. Then work forward till you find the problem node.

1 Like

After about a week of testing I have disconnected about fifty nodes and waited a few hours to check if the problem was occurring I found these two nodes which when activated give an error.

  • They serve respectively to send a warning of voltage too high or low (I have the operator's cabin very close by) .
  • Another alert is used to warn via alexa of an overload on the meter to avoid disconnection after a few minutes of overload.
[
    {
        "id": "849f833ae6e15879",
        "type": "comment",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "avvisi ed allarmi",
        "info": "",
        "x": 220,
        "y": 1960,
        "wires": []
    },
    {
        "id": "738bc12abfce592a",
        "type": "switch",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gte",
                "v": "250",
                "vt": "str"
            },
            {
                "t": "lte",
                "v": "200",
                "vt": "str"
            },
            {
                "t": "btwn",
                "v": "210",
                "vt": "num",
                "v2": "249",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 710,
        "y": 2080,
        "wires": [
            [
                "a340daf1baf7033b"
            ],
            [
                "a340daf1baf7033b"
            ],
            [
                "d7f3fe2f2d471cb6"
            ]
        ]
    },
    {
        "id": "d7f3fe2f2d471cb6",
        "type": "change",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 920,
        "y": 2120,
        "wires": [
            [
                "a340daf1baf7033b"
            ]
        ]
    },
    {
        "id": "a340daf1baf7033b",
        "type": "trigger",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "op1": "",
        "op2": "0",
        "op1type": "pay",
        "op2type": "str",
        "duration": "0",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 920,
        "y": 2060,
        "wires": [
            [
                "21dcf73a6769abe5"
            ]
        ]
    },
    {
        "id": "21dcf73a6769abe5",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "function 1",
        "func": "var msg1 = \"la tensione di casa, ha valori fuori norma,    \";\nvar msg2 = msg.payload;\nvar msg3 = \"  Ciaone\";\n\n\nreturn [{payload:msg1+msg2+msg3}]\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1080,
        "y": 2060,
        "wires": [
            [
                "6d57981c3d2da24a"
            ]
        ]
    },
    {
        "id": "5c3a6698c64bc1b5",
        "type": "alexa-remote-routine",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "account": "e0d0608560b4720d",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "msg",
                    "value": "payload"
                },
                "volume": {
                    "type": "num",
                    "value": "25"
                },
                "mode": "set",
                "devices": [
                    "18e395e9bf2e4604bad62de8bf305428"
                ]
            }
        },
        "x": 1490,
        "y": 2060,
        "wires": [
            []
        ]
    },
    {
        "id": "4083cf1f3fe2caa1",
        "type": "telegram sender",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "testdomo",
        "bot": "65de0924a6725207",
        "haserroroutput": false,
        "outputs": 1,
        "x": 1420,
        "y": 2120,
        "wires": [
            []
        ]
    },
    {
        "id": "60a55c27950726e3",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "function 2",
        "func": "var voltage = flow.get(\"voltage\") || 0;\nvoltage = voltage.toString();\n\nvar message = \"tensione fuori norma,la lettura è di \" + voltage + \" volts\";\nmsg.payload = message;\n\nvar msg1 = msg.payload\nmsg.payload = {}\n\nmsg.payload.chatId = \"-1001855120388\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1240,
        "y": 2120,
        "wires": [
            [
                "4083cf1f3fe2caa1"
            ]
        ]
    },
    {
        "id": "6d57981c3d2da24a",
        "type": "time-range-switch",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "lat": "",
        "lon": "",
        "startTime": "22:00",
        "endTime": "7:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 1230,
        "y": 2060,
        "wires": [
            [],
            [
                "5c3a6698c64bc1b5",
                "60a55c27950726e3"
            ]
        ]
    },
    {
        "id": "33e192d3fd034486",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "Read variable(s) for Alexa",
        "func": "// Get the flow variable(s) to be used in the message\nvar voltage = flow.get(\"voltage\") || 0;\n\n// Convert them to a string\nvoltage = voltage.toString();\n\n\nvar message = \"la tensione è di <break time='0.5s'/>\"+voltage+ \"volts .<break time='0.25s'/>\";\n\nmsg.payload = message;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 2080,
        "wires": [
            [
                "738bc12abfce592a"
            ]
        ]
    },
    {
        "id": "e0befd265a991399",
        "type": "inject",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "60",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 270,
        "y": 2080,
        "wires": [
            [
                "33e192d3fd034486"
            ]
        ]
    },
    {
        "id": "3586afff621062f1",
        "type": "switch",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gte",
                "v": "3750",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 690,
        "y": 2280,
        "wires": [
            [
                "8026d55f61107576"
            ]
        ]
    },
    {
        "id": "14487cd6b31fb767",
        "type": "alexa-remote-routine",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "account": "e0d0608560b4720d",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "msg",
                    "value": "payload"
                },
                "volume": {
                    "type": "num",
                    "value": "25"
                },
                "mode": "set",
                "devices": [
                    "18e395e9bf2e4604bad62de8bf305428"
                ]
            }
        },
        "x": 1450,
        "y": 2220,
        "wires": [
            []
        ]
    },
    {
        "id": "a2de2cca9f04824a",
        "type": "telegram sender",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "msg to gruppodomo",
        "bot": "65de0924a6725207",
        "haserroroutput": false,
        "outputs": 1,
        "x": 1460,
        "y": 2320,
        "wires": [
            []
        ]
    },
    {
        "id": "16ae92586ba8dd67",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "function 5",
        "func": "var power = flow.get(\"power\") || 0;\npower = power.toString();\n\nvar message = \"sovraccarico,la lettura è di \" + power + \" watts spegnere apparecchio\";\nmsg.payload = message;\n\nvar msg1 = msg.payload\nmsg.payload = {}\n\nmsg.payload.chatId = \"-1001855120388\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 2320,
        "wires": [
            []
        ]
    },
    {
        "id": "8026d55f61107576",
        "type": "time-range-switch",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "lat": "",
        "lon": "",
        "startTime": "23:59",
        "endTime": "6:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 870,
        "y": 2280,
        "wires": [
            [],
            [
                "16ae92586ba8dd67",
                "bfa80fe7ec7ffb47",
                "f3e087cf92f0443d"
            ]
        ]
    },
    {
        "id": "cf119dde6c102cd0",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "Read variable(s) for Alexa",
        "func": "// Get the flow variable(s) to be used in the message\nvar power = flow.get(\"power\") || 0;\n\n// Convert them to a string\n//power = power.toString();\n\n\n//var message = \"la potenza è di <break time='0.5s'/>\"+power+ \"watts .<break time='0.25s'/>\";\n\nmsg.payload = power;\nreturn msg;\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 2280,
        "wires": [
            [
                "3586afff621062f1"
            ]
        ]
    },
    {
        "id": "52785f42c9a8c43a",
        "type": "inject",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": "1",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 270,
        "y": 2280,
        "wires": [
            [
                "cf119dde6c102cd0"
            ]
        ]
    },
    {
        "id": "bfa80fe7ec7ffb47",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "function 6",
        "func": "var msg1 = \"avviso di sovraccarico <break time='0.25s'/> spegnere o abbassare apparecchio <break time='0.25s'/>   \";\nvar msg2 = msg.payload;\nvar msg3 = \" watts \";\n\n\nreturn [{payload:msg1+msg2+msg3}]\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 2260,
        "wires": [
            [
                "14487cd6b31fb767",
                "f127f1d53de9eb25"
            ]
        ]
    },
    {
        "id": "f3e087cf92f0443d",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "function 7",
        "func": "var power = flow.get(\"power\") || 0;\npower = power.toString();\n\nvar message = \"sovraccarico,la lettura è di \" + power + \" watts spegnere apparecchio\";\nmsg.payload = message;\n\nvar msg1 = msg.payload\nmsg.payload = {}\n\nmsg.payload.chatId = \"-1001654395886\"\nmsg.payload.type = \"message\"\nmsg.payload.content = msg1\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 2380,
        "wires": [
            [
                "11f773a74b83416b"
            ]
        ]
    },
    {
        "id": "11f773a74b83416b",
        "type": "telegram sender",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "msg to Avvisi",
        "bot": "c254c8951ae33eec",
        "haserroroutput": false,
        "outputs": 1,
        "x": 1430,
        "y": 2380,
        "wires": [
            []
        ]
    },
    {
        "id": "5fa1aa10b7918747",
        "type": "comment",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "alert sovraccarico",
        "info": "",
        "x": 380,
        "y": 2220,
        "wires": []
    },
    {
        "id": "591713b32c85cbce",
        "type": "comment",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "alert tensione di rete",
        "info": "",
        "x": 390,
        "y": 2020,
        "wires": []
    },
    {
        "id": "f127f1d53de9eb25",
        "type": "alexa-remote-routine",
        "z": "0420bb4bf87242a2",
        "d": true,
        "name": "",
        "account": "e0d0608560b4720d",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "msg",
                    "value": "payload"
                },
                "volume": {
                    "type": "num",
                    "value": "40"
                },
                "mode": "set",
                "devices": [
                    "G091AA10139601L8"
                ]
            }
        },
        "x": 1450,
        "y": 2280,
        "wires": [
            []
        ]
    },
    {
        "id": "4c945cd3f0e80e15",
        "type": "mqtt in",
        "z": "0420bb4bf87242a2",
        "name": "Voltaggio",
        "topic": "tele/sensore_energia/SENSOR",
        "qos": "2",
        "datatype": "json",
        "broker": "22f544be.780a3c",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 200,
        "y": 260,
        "wires": [
            [
                "723fc828f32b513d"
            ]
        ]
    },
    {
        "id": "723fc828f32b513d",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "name": "",
        "func": "// Save the reading(s) in a flow variable\n\nflow.set(\"voltage\", msg.payload.ENERGY.Voltage);\n\nreturn null;\n",
        "outputs": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 260,
        "wires": []
    },
    {
        "id": "5d82858f38077a66",
        "type": "mqtt in",
        "z": "0420bb4bf87242a2",
        "name": "sensore potenza",
        "topic": "tele/sensore_energia/SENSOR",
        "qos": "2",
        "datatype": "json",
        "broker": "22f544be.780a3c",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 220,
        "y": 140,
        "wires": [
            [
                "1705132c3f20686c"
            ]
        ]
    },
    {
        "id": "1705132c3f20686c",
        "type": "function",
        "z": "0420bb4bf87242a2",
        "name": "",
        "func": "// Save the reading(s) in a flow variable\n\nflow.set(\"power\", msg.payload.ENERGY.Power);\n\nreturn null;\n",
        "outputs": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 140,
        "wires": []
    },
    {
        "id": "e0d0608560b4720d",
        "type": "alexa-remote-account",
        "name": "alexa",
        "authMethod": "proxy",
        "proxyOwnIp": "10.0.0.202",
        "proxyPort": "3456",
        "cookieFile": "/data/authFile.cookie",
        "refreshInterval": "1",
        "alexaServiceHost": "alexa.amazon.it",
        "pushDispatchHost": "",
        "amazonPage": "amazon.it",
        "acceptLanguage": "it-IT",
        "onKeywordInLanguage": "",
        "userAgent": "",
        "usePushConnection": "on",
        "autoInit": "on",
        "autoQueryActivityOnTrigger": "on"
    },
    {
        "id": "65de0924a6725207",
        "type": "telegram bot",
        "botname": "domotest_bot",
        "usernames": "test",
        "chatids": "",
        "baseapiurl": "",
        "updatemode": "polling",
        "pollinterval": "300",
        "usesocks": false,
        "sockshost": "",
        "socksprotocol": "socks5",
        "socksport": "6667",
        "socksusername": "anonymous",
        "sockspassword": "",
        "bothost": "",
        "botpath": "",
        "localbotport": "8443",
        "publicbotport": "8443",
        "privatekey": "",
        "certificate": "",
        "useselfsignedcertificate": false,
        "sslterminated": false,
        "verboselogging": false
    },
    {
        "id": "c254c8951ae33eec",
        "type": "telegram bot",
        "botname": "Avvisi",
        "usernames": "test",
        "chatids": "",
        "baseapiurl": "",
        "updatemode": "polling",
        "pollinterval": "300",
        "usesocks": false,
        "sockshost": "",
        "socksprotocol": "socks5",
        "socksport": "6667",
        "socksusername": "anonymous",
        "sockspassword": "",
        "bothost": "",
        "botpath": "",
        "localbotport": "8443",
        "publicbotport": "8443",
        "privatekey": "",
        "certificate": "",
        "useselfsignedcertificate": false,
        "sslterminated": false,
        "verboselogging": false
    },
    {
        "id": "22f544be.780a3c",
        "type": "mqtt-broker",
        "name": "Mosquitto",
        "broker": "10.0.0.202",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "compatmode": 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": ""
    }
]

in the syntax, I cannot see what is causing the error.

Which two nodes? The flow you provided has 25 nodes in it. Try adding a catch node connected to a debug node (set to display the complete msg object) to see if that helps.

If you can point to the nodes that are causing the error and can provide the data going into the node people might be able to spot the issue.

in catch I selected the nodes in the first alert , but so far it has not returned any errors yet

If you want people to help you and they ask questions you need to answer them or people will stop looking at your problem,

I know the nodes that give that error are the ones posted 3 hours ago ( because enabling them after a while the error appears ) , I enabled catch as you suggested but it still doesn't give me details .