TsgcWebSocketClient | WebSocket Redirections

When the client connects to a WebSocket server, the server can return an HTTP Response Code 30x. If the Response code it's a 301, means that the location has been moved permanently, and the new url is informed in the Location HTTP Header.

 

The WebSocket client, handle redirections automatically, so if detects the Server Response contains a redirection, it will disconnect the actual connection and try to connect with then new Location URL.

 

Example

  1. Client first tries to connect to url ws://127.0.0.1:5000
  2. Server returns a Response Code of 301 and contains a Header Location with the value ws://80.50.1.2:3000
  3. Client reads the Response from server, detects that it's a redirection and reads the Location
    1. First Disconnects the actual connection.
    2. Update the URL property with the value of Location Header (ws://80.50.1.2:3000)
    3. Connects to the new server.