Get calling ip address from client connecting to a listening "tcp in" node

200 views
Skip to first unread message

David Fernandez

unread,
May 14, 2018, 10:33:36 AM5/14/18
to Node-RED
I'd like to get the src/port address from a client connecting to a "tcp in" node.
The reason is to be able to diferentiate them , and respond acordingly based on config 

The only property I see is _session, but can't find info about it.
I bet that somewhere is the relation of session id <-> Tcp connection.

Someone knows where can I find this information?

Thanks.

Dave C-J

unread,
May 14, 2018, 11:17:04 AM5/14/18
to node...@googlegroups.com
It should also give you ip and port  (below is using ipv6 but hey...




David Fernandez

unread,
May 15, 2018, 1:37:05 AM5/15/18
to node...@googlegroups.com
Hi Dave, 
Thanks for the response, but I can't see that properties:
Maybe i'm running old version?
Node red version: 0.18.4
node -v : v10.0.0

Do you know where can I check beyond?



2018-05-14 17:16 GMT+02:00 Dave C-J <dce...@gmail.com>:
It should also give you ip and port  (below is using ipv6 but hey...




--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/Uvd6Z8HF4Go/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/CACXWFwK5Pd7BgRTXWyW0QXPe6EqfzkpCtVmwtL8Bi4NgjirKBg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

David Fernandez

unread,
May 22, 2018, 10:10:05 AM5/22/18
to Node-RED
This is for UDP node, but not for TCP node

El dilluns, 14 maig de 2018 17:17:04 UTC+2, Dave C-J va escriure:

Dave C-J

unread,
May 23, 2018, 9:14:54 AM5/23/18
to node...@googlegroups.com
well the UDP node does similar



David Fernandez

unread,
May 23, 2018, 11:42:57 AM5/23/18
to Node-RED
Sorry, maybe I did'nt explained very well.:
I'd like to get the src address and src port in a message from TCP IN node.

I see that in UDP but NOT in TCP. And don't know if it is normal or not.
Also I can't find references on that.

El dimecres, 23 maig de 2018 15:14:54 UTC+2, Dave C-J va escriure:

Dave C-J

unread,
May 23, 2018, 1:23:30 PM5/23/18
to node...@googlegroups.com
The first example I showed WAS from a TCP node. You then said you wanted UDP, so the second was UDP. 
What version of NodeRED are you using ?

sent from phone

steve rickus

unread,
May 23, 2018, 4:03:56 PM5/23/18
to Node-RED
According to an earlier response, his versions are:


Node red version: 0.18.4
node -v : v10.0.0

So the node-red version is good, and the TCP In node should be returning the ip and port information...
However, his version of nodejs is perhaps too new?!? Could that be causing some of the node's info to be missing?

I wouldn't think so -- but perhaps if you dropped back to nodejs v4.11.2 LTS, you may have fewer issues.
--
Steve

Nick O'Leary

unread,
May 23, 2018, 4:05:27 PM5/23/18
to Node-RED Mailing List
but perhaps if you dropped back to nodejs v4.11.2 LTS, you may have fewer issues.

No! v4 is no longer supported by node.js   If you want LTS, then use Node 8

Nick

--
http://nodered.org
 
** We're moving this mailing list over to the new Node-RED Forum: https://discourse.nodered.org **

 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

steve rickus

unread,
May 23, 2018, 4:13:31 PM5/23/18
to Node-RED
Oops, my mistake! You are right, I meant v 8.11.2 LTS (which is what I installed earlier this week)...

David Fernandez

unread,
May 24, 2018, 4:30:14 AM5/24/18
to Node-RED

Hi Steve, Dave
Thanks for your patienceI've downgraded nodejs to v8.11.2, and reboot server. (ubuntu server 16.04.4 LTS)
Unfortunately, nothing changed. This is my msg debug. Only _session property but not ip and port. 
Someone could tell me what version of OS, node-red, nodejs is using, and can get tcp ip and port ?
If necessary, I can reinstall whole OS into a new vmware machine. I also have tested with raspbian.























El dimecres, 23 maig de 2018 22:13:31 UTC+2, steve rickus va escriure:

Simon Walters

unread,
May 24, 2018, 6:48:35 AM5/24/18
to Node-RED
Can you show us screenshot of how you've configured your TCP in node? (and/or an export of your flow)
Smon

David Fernandez

unread,
May 24, 2018, 7:06:57 AM5/24/18
to Node-RED
Sure!
I execute an: echo Text to send | ncat IP 5000

Screenshot:



Also I show the "info" from tcp in node: I don't see an explanation of ip and port like I see in the udp node.






Export:
[{"id":"74c115d5.49079c","type":"tcp in","z":"7990a864.279908","name":"","server":"server","host":"","port":"5000","datamode":"single","datatype":"buffer","newline":"","topic":"","base64":false,"x":240,"y":220,"wires":[["3e62ebbd.30fa44"]]},{"id":"3e62ebbd.30fa44","type":"debug","z":"7990a864.279908","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":460,"y":220,"wires":[]}]



So, I've tested: node-red versions 0.18.6 and 0.18.4 and nodejs v8.11.2 and 10.0.0 on ubuntu and raspbian. (and the docker version)


El dijous, 24 maig de 2018 12:48:35 UTC+2, Simon Walters va escriure:

Dave C-J

unread,
May 24, 2018, 9:43:43 AM5/24/18
to node...@googlegroups.com
Wow - subtle... yes indeed. If set to single buffer the properties aren't there... If you set it to stream of buffers they are...
let me investigate...

David Fernandez

unread,
May 24, 2018, 9:56:03 AM5/24/18
to Node-RED
Hi, Dave, 
Now I see that if I wire directly a stream tcp node to debug node, I don't receive nothing in debug window!!. That's why I didn't notice ip an port!!
It must pass through a empty function, and voilà! 





El dijous, 24 maig de 2018 15:43:43 UTC+2, Dave C-J va escriure:

Dave C-J

unread,
May 24, 2018, 10:24:44 AM5/24/18
to node...@googlegroups.com
so the subtlety is... that in "single" mode it uses the closing of the socket as the trigger to send - and "of course" as it has now just closed there is no socket.remoteAddress property to report anymore !

Dave C-J

unread,
May 24, 2018, 10:24:58 AM5/24/18
to node...@googlegroups.com
Will look at getting a fix added.

David Fernandez

unread,
May 24, 2018, 10:49:52 AM5/24/18
to Node-RED
May I ask where the source code is, or some docs to "clone" node and experiment with source?.
Although I find node-red impressive (just few days of learning),  I find docs little scanty.

By now, I'll use it as stream mode, 

Thanks, Dave and others to respond.

El dijous, 24 maig de 2018 16:24:58 UTC+2, Dave C-J va escriure:

Dave C-J

unread,
May 24, 2018, 12:08:09 PM5/24/18
to node...@googlegroups.com
Github link from main page.
Reply all
Reply to author
Forward
0 new messages