# TCP In get sender IP address

**URL:** <https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351>\
**Category:** General\
**Created:** [15 January 2020 02:20 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351 "2020-01-15T02:20:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)\
**Post date:** [15 January 2020 02:20 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351/1 "2020-01-15T02:20:46Z")

</div>

I would like to be able to process incoming TCP messages based on the sender IP address. Is there any way to retrieve the source IP/Port details on a TCP In node, perhaps in `_session.id`?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 January 2020 05:29 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351/2 "2020-01-15T05:29:21Z")

</div>

IP and port are available directly on the message object. Try `msg.ip` and `msg.port`.

---

<div class="post-metadata">

**Author:** ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)\
**Post date:** [15 January 2020 14:00 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351/3 "2020-01-15T14:00:33Z")

</div>

It looks like there is something a bit deeper going on as some of the messages have the keys in the msg object when others don't. I believe it's tied to a HAProxy instance (with Proxy Protocol and health checks) in front of the incoming TCP packets. I don't quite understand how it would not have source information for those packets but I'm willing to move on because it does look like all of the information I need is coming through when I need it.

 ![Screen Shot 2020-01-15 at 8.57.25 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf82c4fb1d863bf4a8d3a48bd47ef01aeb07426f.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 January 2020 16:47 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351/4 "2020-01-15T16:47:47Z")

</div>

If the data comes via a proxy, the proxy has "interfered" with the packets and they are generally listed as coming from the proxy rather than the originating IP. This is why HTTP traffic usually has an extra header added that tells you the originating IP. That is actually added by the proxy.

The whole point of a proxy is that it intercepts the traffic and has the ability to do things to it. Like filter out components, terminate TLS connections and so on.

---

<div class="post-metadata">

**Author:** ![mlschuh](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mlschuh](https://discourse.nodered.org/u/mlschuh)\
**Post date:** [15 January 2020 18:15 UTC](https://discourse.nodered.org/t/tcp-in-get-sender-ip-address/20351/5 "2020-01-15T18:15:16Z")

</div>

Yup! I'm taking a proxy into account with HAProxy's Proxy Protocol and it works well in our situation. Where I'm still a bit confused is that I am getting an incoming message, the carriage return in the first log message, that has a session attached but does not have the ip/port keys. I would have expected that every single message coming out of a TCP In node would have the ip/port.

In the end, it doesn't affect my situation but since that is what I saw at first, I (incorrectly) assumed that all of the packets wouldn't have IP information.
