Forward original TCP/IP received msg to WAN

I have task on which I want to receive some msg via TCP/IP on port 8037 and then value of this msg will be used on Home Assistant + at the same time I need to forward this msg to WAN, so that also native app of OilFox will receive data.

Current flow:
Image1

Current status is that I receive data, but I have problem with extracting "value" from received msg + I also do not know how to forward original msg to WAN via port 80.

[{"id":"caae2049.f90ed","type":"tab","label":"TCPIP_OilFox","disabled":false,"info":""},{"id":"60de048b.3f9e4c","type":"tcp in","z":"caae2049.f90ed","name":"","server":"server","host":"","port":"8037","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":80,"y":40,"wires":[["632203b6.d3214c","a06215a7.ff18c8","24443d9c.0c5022"]]},{"id":"632203b6.d3214c","type":"json","z":"caae2049.f90ed","name":"","property":"payload","action":"","pretty":true,"x":270,"y":40,"wires":[["a06215a7.ff18c8"]]},{"id":"a06215a7.ff18c8","type":"debug","z":"caae2049.f90ed","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":200,"wires":[]},{"id":"24443d9c.0c5022","type":"tcp out","z":"caae2049.f90ed","host":"metering.prod.oilfox.io","port":"80","beserver":"client","base64":false,"end":true,"name":"","x":340,"y":280,"wires":[]}]

So, when I will extract value from msg I know how to export data to HA, because I'm already using Node-RED to HA pluging via "entity" on other Flows.

So on short:
-need to export value data from received msg
-need to export battery data from received msg
-need to forward original received msg (port 8037) to WAN (port 80) - (this is because I re-routed internal device on static IP via NAT destination / source rule)

msg received (non-raw):

27. 10. 2020 14:51:30node: 632203b6.d3214c
msg : string[26]
"Ignored non-object payload"
27. 10. 2020 14:51:31node: a06215a7.ff18c8
msg.payload : buffer[956]
buffer[956]
POST /v1/meter HTTP/1.1
Host: metering.prod.oilfox.io
User-Agent: ESP8266HTTPClient
Connection: close
Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0
Content-Type: application/json
Content-Length: 744

{"token":"00000000-0000-0000-0000-000000000000","hwid":"<RESTRICTED>","value":12.5575,"battery":778,"version":"176.OF_PROD","temperature":20.125,"serialNumber":"<RESTRICTED>","measurements":[[12.5575,21.14229,29.8816,30.12197,39.58241,39.99448,58.76082,62.10889,79.29562,96.46519,129
27. 10. 2020 14:51:35node: 632203b6.d3214c
msg : string[26]
"Ignored non-object payload"
27. 10. 2020 14:51:36node: a06215a7.ff18c8
msg.payload : buffer[212]
buffer[212]
GET /v1/firmware/get-latest-version?hwid=<RESTRICTED>&v=176.OF_PROD HTTP/1.1
Host: metering.prod.oilfox.io
User-Agent: ESP8266HTTPClient
Connection: close
Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0

Can anybody help me regarding that?

Thank you and sorry if there is some mistake - this is my first post to Node-RED..

Anybody? I'm lost withouth your help..

I am not entirely sure what the debug is showing. Is all of that text, including the JSON string {"token":"0000..." ...} contained inside the 956 byte buffer?

So.. can be "tcp/ip in" be forwarder 1:1 to "tcp/ip out" component..

I don't know about that, my question was aimed at the other part of the question, extracting data from the message.

That looks more like an http request than raw TCP . maybe you need to use an http in and out pair for the input and an http request for the output. To listen on port 8037 you will need to run node-red on port 8037

I tried both variant, to listen on port 80 and on port 8037 and I do not get anything..
On which port I do want to receive msg I configure this on EdgeRouter, so it's not questionable if this works..

The only thing which is working is to receive as TCP IN component...

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