# Forward original TCP/IP received msg to WAN

**URL:** <https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972>\
**Category:** General\
**Created:** [28 October 2020 17:51 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972 "2020-10-28T17:51:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kslb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kslb/32/49273_2.png) [@kslb](https://discourse.nodered.org/u/kslb)\
**Post date:** [28 October 2020 17:51 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/1 "2020-10-28T17:51:23Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95aa26e360a5ab0d463593ad9a3681a2376c7e2b.png)

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.

```auto
[{"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):

```auto
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..

---

<div class="post-metadata">

**Author:** ![kslb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kslb/32/49273_2.png) [@kslb](https://discourse.nodered.org/u/kslb)\
**Post date:** [30 October 2020 08:57 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/2 "2020-10-30T08:57:17Z")

</div>

Anybody? I'm lost withouth your help..

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 October 2020 11:36 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/3 "2020-10-30T11:36:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kslb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kslb/32/49273_2.png) [@kslb](https://discourse.nodered.org/u/kslb)\
**Post date:** [31 October 2020 08:06 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/4 "2020-10-31T08:06:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 October 2020 08:46 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/5 "2020-10-31T08:46:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [31 October 2020 08:53 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/6 "2020-10-31T08:53:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kslb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kslb/32/49273_2.png) [@kslb](https://discourse.nodered.org/u/kslb)\
**Post date:** [2 November 2020 08:20 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/7 "2020-11-02T08:20:06Z")

</div>

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..

 ![8618bb6e-f777-4e55-aafa-d37013542cdb](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/5580bf7c0177d8220a13a659997a73ae660d2ef3.png)

 ![71432432-19ae-4fc1-9abf-e2ece7057412](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/b/4b4760bba112e7dc71680c37bff7c3a1adacb44f.png)

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 January 2021 08:20 UTC](https://discourse.nodered.org/t/forward-original-tcp-ip-received-msg-to-wan/34972/8 "2021-01-01T08:20:15Z")

</div>

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