By James Smith on Sunday, 24 April 2022
Posted in General
Replies 1
Likes 0
Views 0.9K
Votes 0
Could possibly use message names (in the payload) to same sgc server to determine how to process, but I could also see using nginx to do routing to multiple sgc servers listening on different ports. Any opinions on this?

Thanks,
james
Hello,

Usually I will use diferent servers only if the data to be processed are completely different between servers, example: 1 server must get data from a database and another server must broadcast messages between clients. Keep in mind that connections are persistent using the websocket protocol (vs HTTP where connections are opened and closed, well HTTP/2 uses a semi-persistent connection, but usually is closed after some timeout), so if for example you want exchange messages between clients, and the connections are attached to different servers, you won't be able to exchange messages unless the servers are connected too and some mechanism is implemented to broadcast messages between them.

The websocket protocol has an initial handshake where server and client agree to create a new connection, in this handshake you can pass some parameters (like an HTTP request), by default the websocket protocol uses the document '/' but you can pass whatever you need, example you can pass as a parameter the server where the client should connect


oClient := TsgcWebSocketClient.Create(nil);
oClient.URL := 'ws://http://www.esegece.com:2052/server1';
oClient.Active := True;


You can use NGINX to inspect the initial handshake and route the connection to the internal server behind NGINX.

Kind Regards,
Sergio
·
2 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post