Need some basic example how tcp-client is setup

Hi! does anyone knows how to make tcp-client setup to listen to a specific address and port. My apology if this may be simple but I don't figured it out yet how to make it work. I got the module from this link I also tried the tcp request and works fine (Server: localhost Port: 7811) I can send string and receive message, but I wanted to try tcp-client.

Thanks for the time,

Do you need to create dynamic ports? If not you can use the core tcp-in node to create a listener. The tcp-request node creates an outbound connection.

I realized that the Tcp Request fits to my needs. The reason I tried to focus on the Tcp client, I thought it would be easy to modify it later, unlike the Tcp Request which included in the node red folder with the other category nodes(network,functions, storage & etc). Is it possible to have Tcp request only and cloned it then modify to my own need? I'm still new to node red(but I was able to do the lower-case example) and really appreciate any guide that will help me continue my application in mind.

Thank you,

If you are feeling the need to amend a node, there is a good chance that you haven't thought through the opportunities that Node-RED brings and the slightly different way you may need to think about things.

It would be better if you explained what it is that you want to achieve.

1 Like

The core nodes source is in here
the 32-tcpin files contain all three tcp nodes so you can take it apart as you wish (and rename of course)

1 Like

Thank you for helping me out...I will post later if I have other questions.

Regards & more power,

I have a device that I would to control and I simply want my customised node functions same as tcp request node but wanted also to add or change to fit my need.

OK, that is more reasonable for sure.

Hi, thank you for creating and sharing these node modules. I'm still new in javascript so I'm still stuck in putting it together. So far here is what I did.

  1. Create a folder to place the js, html and jason file.
  2. Copy codes from 31-tcpin.js (function TcpGet part only).
  3. Copy codes from 31-tcpin.html (in the part tcp request).
  4. I created the jason file but not sure if I made it right.

When I open the terminal(on raspberry pi) I did the ff. commands
a.) cd to my folder(node-red-contrib-tcp-client)
b.) sudo npm install
c.) cd ~/.node-red
d.) sudo npm link node-red-contrib-tcp-client
Issuing the commands above did not show any errors but it also did not work. Can you help me try to identify what I'm missing? I also uploads the files I'm working on below.
package.json (2.7 KB)
tcp-client.html.txt (8.4 KB) tcp-client.js.txt (12.7 KB)

Thank you for the time,

No showing of node in the palette and the category I created. There must be conflicting between the existing node-red-contrib-tcp-client I have installed earlier. I will try to remove it...and see the result.

Give your new one a different name.

Hi!, just want to ask if I need to change the name of the html and js file?
"<script type="text/x-red" data-template-name="tcp-client">" the html file(tcp-client), this should be change too?

I don't know if it is essential, probably not, but I always name them according to the node for consistency.

okay... I will try it. Thanks for the suggestion.

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