Python Socket Communication Server 1 Client 2 - python-3.x

We use Python to communicate sockets with one server (laptop) and four clients (Raspberry Pi).
Can I send data separately from the server to the client 2 when I send specific data from client 1 to the server?
Both client 1 and client 2 have socket communication with the server, but I don't know how to send data from the server to client 2 even if the data is sent from client 1 to server.

Related

Get Room object in other node in socket.io in multiple socket.io server environment

I have two socket io servers, and two clients are connected on different servers say, client 1 is connected to server 1 and client 2 is connected to server 2.
Now client 1 creates a room in its socket.io server i.e in server 1 and when client 2 tries to join that room it actually cannot find that room because that room is in server 1 and client 2 is trying to find the room in server 2 which is not created there.
Currently, I'm using a PostgreSQL adapter to route events to different clients connected on different servers. The events are passing successfully but client 2 is not able to join the room.
So how can I get the room information which is created on server 1 in the second socket.io server?
If there is any other way to do it. Please tell me.

rpyc, how to handle disconnect and reconnect

using w10/64, python 3.6, rpyc
I have a server receiving serial data and want the data to be published to any client asking for a connection.
In the server I add every client into a connection list and when detecting changes in the data publish it to all clients.
Clients send a "startListening" request to the server including ip and port. The server then opens its own connection to the client to update it with the new data.
I have an "on_disconnect" method in my servers commands class and it gets triggered when a client stops.
When the client restarts and sends a "startListening" again I get an EOFError on the server showing the clients ip/port.
How can I properly detect and close the client connection to allow for a reconnect?

TCP connection - client sending FIN in middle of communication

I have azure VM which act as a TCP server (java program which listen on a port). TCP client (ncat) sits in corporate network. There is a corporate firewall in between. Client initiates a connection with server by sending message and after that server keeps sending the one line message to client at every 3 second. client do receive 3 or 4 messages but after that it stops receiving any message. There is no exception at server side. When client and server both are in corporate network, i don't experience this issue. The wire shark capture is below. I don't understand why client is sending FIN (highlighted in yellow) in between. Any suggestions please.
The issue was with the tcp-halfclose-timer value in firewall between Azure and Corporate network. It was set to 10 second, so once FIN is sent from client, after 10 second server was not able to send any messages to client as firewall was closing the half closed connection after 10 second. The value is changed to 1 hour and after that the issue got resolved.

Transporting Socket.IO socket to another server

How can I transport a Websocket that connects to Server A (Which is using Socket.IO) to Server B each time data is sent, and be able to send data to that socket from Server B. But on top of all of that, the socket should not be able to send data to Server B directly, all data going into the servers must be going to server A. Would I be able to just pass the socket object from Server A to B? Note: Any request server B gets is being authenticated from Server A.
I hope this isn't too confusing the way a worded it. Here's a text diagram.
Socket -> Server A -> Server B -> Socket
You cannot pass a socket from one server to another. A given TCP socket (which socket.io is based on) is between two specific endpoints only and you cannot change that once the socket has been connected.
Your question is not entirely clear, but it sounds like maybe you just want server A to act like a proxy where the client connects to server A and then server A can decide to forward some data on to server B. You can either use a pre-existing proxy server that supports your method of authentication in place of server A or if you already have a server A process, then you can add proxying capabilities to it by just having it send appropriate packets of information to server B.
Or, you can have a socket connect to server A, authentication through server A and as part of that connection, it could receive a token which would it could then use to directly connect to server B. Server A and B would share access to some "token store" so that server B could check the token store to see if any incoming connection has presented a valid token or not.

How to check nodejs socket is exists on another nodejs server

I wants to setup a nodejs chat app on two servers, but my concern is that will node check that the user who wants to send messages on the socket is connected on different socket.
suppose nodejs1 is on server1 and listing on 3001 and nodejs2 is on server2 listing on 3002
user 1 is connected to 3001 and user 2 is connected to 3002
user 1 wants to send a message to user 2
user 1 and user 2 socket is stored on db
Is this communication can be possible ?
check it out if https://github.com/indutny/sticky-session can work out for you as if you will use socket.io
Socket.io is doing multiple requests to perform handshake and establish connection with a client. With a cluster those requests may arrive to different workers, which will break handshake protocol.
Sticky-sessions module is balancing requests using their IP address. Thus client will always connect to same worker server, and socket.io will work as expected, but on multiple processes!

Resources