# Setting up a tcp socket on specific port

**URL:** <https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893>\
**Category:** General\
**Created:** [27 January 2021 19:53 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893 "2021-01-27T19:53:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [27 January 2021 19:53 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/1 "2021-01-27T19:53:11Z")

</div>

Hi,

I have a server which emits continuous messages on port xx. I have made a python program to listen and list all messages coming from that server, though a tcp socket (AF\_INET).  
How can I make the same on node-red? I have tried with the tcp-request node, but it is showing a message only if triggered, and doe snot "keep" alive listening on that server/port.

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [27 January 2021 19:56 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/2 "2021-01-27T19:56:06Z")

</div>

Hi @fmarzocca ! Have you tried using the TCP In node instead of the TCP request?

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [27 January 2021 20:02 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/3 "2021-01-27T20:02:39Z")

</div>

Yes, but it does not connect to the TCP socket.  
The TCP IN does not have a field to input the server's IP.

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [27 January 2021 20:09 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/4 "2021-01-27T20:09:11Z")

</div>

And in the TCP request I imagine you tried setting the return option to: never keep connection open ?

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [27 January 2021 20:10 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/5 "2021-01-27T20:10:32Z")

</div>

Yes, I did. Sorry not to have been so much verbose, but I am currently out of my main desk.  
I'm afraid I should write my own node to handle handshaking with that socket.

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [27 January 2021 20:11 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/6 "2021-01-27T20:11:48Z")

</div>

If you know each message sent by this server is separated by a special character, you can set it to: "when character received is" for example: \n

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [27 January 2021 20:12 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/7 "2021-01-27T20:12:49Z")

</div>

Yes, that could be an idea. I will try, thank you!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 January 2021 20:15 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/8 "2021-01-27T20:15:35Z")

</div>

Have you tried the TCP in node set to connect to?

 ![Screenshot_20210127-201330](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d72e5d2f1130e7040f0c3031bea8f47714a7c35.png)

---

<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:** [28 March 2021 20:16 UTC](https://discourse.nodered.org/t/setting-up-a-tcp-socket-on-specific-port/39893/9 "2021-03-28T20:16:15Z")

</div>

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