What is WS/WSS?
WebSocket is a new HTML5 protocol, which provides full-duplex communication between the browser and the server. This protocol conserves server resources and bandwidth, enabling real-time communication. WebSocket is built on top of TCP and transmits data over TCP like HTTP.
Its biggest difference from HTTP is that WebSocket is a two-way communication protocol. Once the connection is established, both the WebSocket server and the client can send or receive data to or from each other actively like Socket. The WebSocket server and client have to complete a handshake to establish a WebSocket connection.
WebSocket Secure (WSS) is the encrypted version of WebSocket.
Why use WS/WSS?
With the increasing popularity and accessibility of the Internet, a multitude of varied web applications are emerging. Many applications require real-time push capabilities of the server (such as broadcast rooms and chat rooms). In the past, many websites used the round robin technique to achieve real-time push. With the round robin technique, the browser sends HTTP requests to the server at specific intervals (for example, per second) and the server returns the most recent data to the browser of the client. However, this method has an obvious disadvantage of inefficiency. The browser must send requests constantly to the server. The headers of HTTP requests may be very long with only a few effective messages, therefore, many bandwidth resources are potentially wasted.
In this situation, HTML5 defines the WebSocket protocol, which can help conserve server resources and bandwidth and facilitate real-time communication. WebSocket provides the full-duplex communication between the browser and the server. This allows the server to send data to the client actively without being solicited by the client.
The communication process of the WebSocket protocol is shown in the following figure:
How to enable WS/WSS on Server Load Balancer?
No configuration is required. The HTTP listener supports the WS protocol and the HTTPS listener supports WSS protocol by default.
The WSS/WS support is available in all regions.
The limitations for WS/WSS protocol are as follows:
- Server Load Balancer is connected to backend ECS instances by using HTTP/1.1. We recommend backend servers use a web server that supports HTTP/1.1.
- If there is no message interaction between Server Load Balancer and a backend ECS instance within 60 seconds, the connection is terminated. If you need to maintain the connection, enable Keepalive to ensure message interaction at the frequency of once every 60 seconds.
WS/WSS protocol support is free of charge.