Hello everybody,
I am a new in Node-Red and I have a question regarding the HTTP node in Node red.
My node-red is running on an virtual operating system (ctrlX Automation from Bosch Rexroth) and I want to send to it json files from a connected device through http (as my device does not support https), however when using the http node in node red it says that the device cannot send http request to a https server, so is their any possibility to receive http requests even though the Node-Red Node is in reality a https node. When I send the http requests through http to a port and I listen to the tcp port i can see the json data in node red, however the device keeps and keeps publishing json messages as it didn't receive the 200 OK status from node red.
I would be really glad, if someone can help me out
Hi, it is not 100% clear what is http, what is https etc.
could you perhaps clarify?
something like
- DEVICE 1
- Node-red on xxx
- HTTP end point
/upload
- IP xxxxxxx
- DEVICE 2
- IP yyyyyy
- Custom application that
POST
s toHTTPS://xxxxxx
Hello Steve,
My Device 1 is ctrlX Automation and Node-Red is running on it.
In Node-Red I was looking to receive Data from my device through the http in node and reply simply with an 200 OK Status using the http response node. However HTTP is not supported by ctrlX Automation (The HTTP receive Node is in reality an https node), so when I want to send data from my device2 to the IP : http://192.168.1.11/8443/node-red/Input, the device is sending an http post request to an HTTPS server.
So i thought, as i am not able to use the http node on node red running on the ctrlX, i will push my device to send HTTP requests to a port http://192.168.1.11/8082 and listen to that port using node-red TCP-IN node, but the device keeps sending the data, as it didn't receive the standard confirmation status 200 OK from node-red.
have you added a debug node to the TCP In? Are you getting the HTTP Request into node-red?
You do realise you will need to manually parse the incoming data and construct a 200 response then send that to the TCP-out node?
but as a trial, I would construct a HTTP Response string for a 200 response and send that upon reception of data - to see if you can get the mechanism working.
yes, i am getting the http request and i can see it.
Concerning the TCP out I simply pass msg.payload= "HTTP/1.1 200 OK".
but i doesn't work (The response is not acknowledged as valid http response ).
You might need to inspect (postman / wireshark / other tool) what a normal response looks like. E.g., it may expect headers or a token or something else.
Also, did you terminate the response with CRLF?
Hello Steve,
I have followed your suggestions and it worked.
I tested the connection with postman but the connection doesn't terminate after postman receive the OK status. What I am using are simply a tcp-in and tcp out node.
Here is my Node-Red flow and I would be really glad if you can help me out. In postman I am sending an POST http request containing a JSON File. I can see the JSON File and I am able to extract it and postman receive the http ok response from node-red. However, the connection doesn't close.
I hope you can help me with that.
[
{
"id": "71e1ac58ae8f5785",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "32f80a696d199e73",
"type": "tcp in",
"z": "71e1ac58ae8f5785",
"name": "",
"server": "server",
"host": "",
"port": "8082",
"datamode": "stream",
"datatype": "buffer",
"newline": "100000",
"topic": "",
"base64": false,
"x": 350,
"y": 1980,
"wires": [
[
"9b1b83bc38bd9bd2",
"6cddd30e35d3aced"
]
]
},
{
"id": "225eec5f0caef39d",
"type": "tcp out",
"z": "71e1ac58ae8f5785",
"host": "",
"port": "",
"beserver": "reply",
"base64": true,
"end": false,
"name": "",
"x": 660,
"y": 1960,
"wires": []
},
{
"id": "9b1b83bc38bd9bd2",
"type": "function",
"z": "71e1ac58ae8f5785",
"name": "",
"func": "msg.payload = \"HTTP/1.1 200 OK \\r\\n\\r\\n\"\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 650,
"y": 2120,
"wires": [
[
"225eec5f0caef39d"
]
]
},
{
"id": "24debaee2abee42a",
"type": "debug",
"z": "71e1ac58ae8f5785",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1150,
"y": 2160,
"wires": []
},
{
"id": "6cddd30e35d3aced",
"type": "function",
"z": "71e1ac58ae8f5785",
"name": "",
"func": "msg.payload = msg.payload.toString('utf8');\nlet body_end = msg.payload.search(\"\\r\\n\\r\\n\");\nlet body = msg.payload.slice(body_end, msg.payload.length);\nmsg.payload=body\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 529.8499755859375,
"y": 2208.89990234375,
"wires": [
[
"d3ee32429f9c84e6",
"3e0cbd3163d2d899"
]
]
},
{
"id": "d3ee32429f9c84e6",
"type": "json",
"z": "71e1ac58ae8f5785",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 810,
"y": 2220,
"wires": [
[
"24debaee2abee42a"
]
]
},
{
"id": "3e0cbd3163d2d899",
"type": "debug",
"z": "71e1ac58ae8f5785",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 2500,
"wires": []
}
]
cheers,
Mo
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.