Sunday, 24 April 2022
  1 Replies
  322 Visits
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?

1 year ago

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://';
oClient.Active := True;

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

Kind Regards,
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf
· Insert · Remove
  Upload Files (Maximum 10MB)