Hi Andrei, thank you for your quick answer. I am using node-red-contrib-mobus, I can read and write to the device from Node-Red but could not "listen" for a connection from device.
I have connected the device via TCP Listen but did not realize how to bind this connection to Modbus.
Is it possible for you to send a flow or tell me how should I procede?
Thank you so much for your help.
Please share more information on how you configured the TCP node and what happened. Knowing what failed may help us to find a solution. The two most common issues when trying to connect a device with TCP is permission issues when using ports below 1024 and missing to add line feed when sending commands to the device. What is the model of the device you are trying to connect to?
No, I just want to bind two TCP ports.
Eg. My device will conect to the port 8502 and Node-Red will connect to the port 8505.
I want to bind these two ports so Node-Red could pool the device.
Can you share a picture from your flow ? I wanted to understand what you mean by "Node-RED TCP listener". I dont understand if you are trying to use a TCP node or using only Modbus contrib node. It would be easy to help you if we have a clear picture of what you already did instead of trying to guess.
Anyway...a new guess on my side. As you are configuring you modbus gateway as a TCP client then you may want to use the Modbus server for testing the connection with your gateway device. Have you already tried this node ?
But you have the plc labelled as a modbus client, not a modbus server. Redraw it with extra lines round the physical devices and draw the arrows client > server.
So is that three separate devices running node-red?
The modbus client is the one that issues, for example, coil read requests. The Server is the one that provides the coil data back to the client. So who in the diagram is asking for the data and who is providing the data?
You still haven't explained fully which is the modbus server/master (the one providing the data) and what is asking for the data.
You can carry on editing the previous post.
If the PLC/Gateway is actually the master then which port is it listening on?
I have just looked back at your earlier posts. You said that if you configure the gateway as a server then you can read and write to it from node-red. In this situation presumably you are reading data that is in the PLC (which is the actual server, the gateway is just a gateway to that server).
Why do you want to change the gateway to be a client? Surely that is only valid if the PLC is operating as a client.
[Edit] I have been blocked too now, for posting too many without a reply.
You mean you want the node-red device to operate as a router? Passing any data it receives on one port to the other?
Sorry, I don't know how to make a router with node red.
So I think what you are actually trying to do is connect a modbus read node to an incoming connection, but I don't know any other way of doing that either.
Perhaps someone with more knowledge of networking can help.
I'm not sure I fully understand what is desired here, but as far as forwarding TCP requests, I was able to do this using:
TCP In (stream of buffers) -> TCP request to Modbus server (return after timeout) -> TCP out (Reply to TCP)
In my setup, I had Node-RED listen (the TCP In) on port 7000, and the TCP request went to a local Modbus server running on port 7001. You'd then have to decode the responses from the TCP request node.
You could also decompose the incoming request, compose a new request with a Modbus node, and then compose the response needed for the TCP out. Doesn't really look like there's an elegant solution here without getting dirty.