“No response from server” appears when sending HTTP request

When I use HTTP request to send a request, the debug console occasionally shows "No response from server". Through monitoring the server, the requesting server did not receive the request. I would like to ask for the reason for this issue. Could it be a network issue or an issue with the version of my node.js or node red (my node.js version is V20.11.0, node red version is v3.1.3), or some other reason? This issue has caused a lot of trouble in the project, so I sincerely seek your advice. Thank you very much.
Here is my code.

[
    {
        "id": "17c00b55beda47d3",
        "type": "tab",
        "label": "流程 7",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "deb3ed1feedce240",
        "type": "http in",
        "z": "17c00b55beda47d3",
        "name": "RFID返回",
        "url": "/PostMessage/RFIDCode",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 361,
        "y": 280,
        "wires": [
            [
                "d7f9d1dbca329fe4"
            ]
        ]
    },
    {
        "id": "d7f9d1dbca329fe4",
        "type": "function",
        "z": "17c00b55beda47d3",
        "name": "解析",
        "func": "var rfidCode = msg.payload[\"code\"];\nvar rfidCardNo = global.get('globalVariable_RFID_LinShiCardNo')||'';\n\nvar globalVariable_Weigh = global.get('globalVariable_Weigh') || \"0\";\nvar floatWeigh = Number(globalVariable_Weigh);\nif(floatWeigh>0.02){\n    return null;\n}\n\nif(rfidCardNo==rfidCode){\n    return null;\n}else{\n    global.set('globalVariable_RFID_LinShiCardNo',rfidCode)\n    msg.payload = {\n        \"rfidCode\": rfidCode\n    }\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 521,
        "y": 340,
        "wires": [
            [
                "6f36379773c09682",
                "69d05c2ab22c803c"
            ]
        ]
    },
    {
        "id": "6f36379773c09682",
        "type": "http request",
        "z": "17c00b55beda47d3",
        "name": "上传信息",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.1.98:9082/bdDocCar/findListByRfidCode",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 561,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "69d05c2ab22c803c",
        "type": "debug",
        "z": "17c00b55beda47d3",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 741,
        "y": 340,
        "wires": []
    }
]

微信图片_20240514170429
微信图片_20240514170436

The http in node needs to be paired with a http response node.
You can then send what response payload you wish and a http statusCode, and headers if you need to also.

An example

[{"id":"deb3ed1feedce240","type":"http in","z":"17c00b55beda47d3","name":"RFID返回","url":"/PostMessage/RFIDCode","method":"post","upload":false,"swaggerDoc":"","x":361,"y":280,"wires":[["d7f9d1dbca329fe4"]]},{"id":"d7f9d1dbca329fe4","type":"function","z":"17c00b55beda47d3","name":"解析","func":"var rfidCode = msg.payload[\"code\"];\nvar rfidCardNo = global.get('globalVariable_RFID_LinShiCardNo')||'';\n\nvar globalVariable_Weigh = global.get('globalVariable_Weigh') || \"0\";\nvar floatWeigh = Number(globalVariable_Weigh);\nif(floatWeigh>0.02){\n    msg = {\n        payload: \"A response message1\",\n        StatusCode: 200\n    }\n    return[msg, null];\n}\n\nif(rfidCardNo==rfidCode){\n    msg = {\n        payload: \"A response message2\",\n        StatusCode: 200\n    }\n    return [msg, null]\n}else{\n    global.set('globalVariable_RFID_LinShiCardNo',rfidCode)\n    msg.payload = {\n        \"rfidCode\": rfidCode\n    }\n    msg.statusCode = 200;\n}\nreturn [null,msg];","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":521,"y":340,"wires":[["69d05c2ab22c803c","d6184997f46ee61a"],["6f36379773c09682","0a86c0a67b56c8d5"]]},{"id":"6f36379773c09682","type":"http request","z":"17c00b55beda47d3","name":"上传信息","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.98:9082/bdDocCar/findListByRfidCode","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":480,"y":420,"wires":[["d6184997f46ee61a"]]},{"id":"69d05c2ab22c803c","type":"debug","z":"17c00b55beda47d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":260,"wires":[]},{"id":"d6184997f46ee61a","type":"http response","z":"17c00b55beda47d3","name":"","statusCode":"","headers":{},"x":770,"y":300,"wires":[]},{"id":"0a86c0a67b56c8d5","type":"debug","z":"17c00b55beda47d3","name":"debug 2489","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":380,"wires":[]}]

This example uses two outputs on function node, you can read about that here Writing Functions : Node-RED

Okay, thank you. I will add a http response node as you mentioned and observe if this problem still occurs

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