Tcp client, websocket

Greetings, is there any guide or example of real use that meets these requirements.

-A TCP node that acts as a client.
-a websocket server that can get the data from the TCP client.
-Identify the connection data of the TCP server, so that the TCP client interprets it based on parameters sent by the websocket client.
-if the TCP client is already handling that connection that a new websocket client requested, simply that this client can receive the data returned by the websocket server.

Example.

+Websocke client 1 connection request to the websocket server, with the paramertrs ?connectaSocket=12

then this defines which socket should receive the data, the idea is that if several websocket clients request an already open data socket then they can receive the data.

For this I have thought of using nodes: websocket in, funtion1 to process the data sent by the websocket client, tcp-client that must receive the ip data, port as parameters, funtion2 to process the data retrieved from the socket, websocket out: to send the data to websocket clients but you should send the data to the correct socket, not to all connected clients.

I know it can be a bit confusing, I hope I make myself clear.

I don't know how to correctly handle different types of connection from a TCP-CLIENT node or if it is possible.
Also identify the websocket client and the parameter sent in order to send the corresponding socket data.

Why would that be a thing? The websocket server node would take data from a websocket client. Either a client in a web page, a node.js or Python microservice (or similar) or a Node-RED websocket-out node.
image
image

Websocket is a protocol related to HTTP. Both are above the TCP layer in the network stack.

Websocket is a point-to-point protocol. It does not include any higher level client or channel knowledge, you have to build that yourself.

To do what you are asking, you should look to use the Socket.IO library instead which already has all these features and more and has both server and client libraries. For example, both Dashboard and uibuilder nodes already use Socket.IO.

It would be best if you try to describe what you want to achieve over a websocket style connection. That way, we can help you get to the most appropriate solution.

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