What are WS and 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.
One major difference between WebSocket and HTTP is that WebSocket is a two-way communication protocol. Once the connection is established, both the WebSocket server and the client can send data to or receive data 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 and 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:
<section class="section" id="section-azg-kwx-wdb">
<h2 class="title sectiontitle" id="h2-url-3">How can I enable WS and WSS on Server Load Balancer?</h2>
<p class="p">No configuration is required. The HTTP listener supports the WS protocol and the HTTPS
listener supports WSS protocol by default.
<div class="note note note-note">
<div class="note-icon-wrapper"><i class="icon-note note"></i></div>
<div class="note-content"><strong>Note</strong> You must upgrade the instance to a guaranteed-performance instance.</a>.
<section class="section" id="section-yts-twx-wdb">
<h2 class="title sectiontitle" id="h2-url-4">Supported regions</h2>
<p class="p">The WS and WSS support is available in all regions.</p>
<section class="section" id="section-zts-twx-wdb">
<h2 class="title sectiontitle" id="h2-url-5">Limits</h2>
<p class="p">The limitations for WS and WSS protocol are as follows:</p>
<ul class="ul" id="ul-a5s-twx-wdb">
<li class="li">Server Load Balancer is connected to backend ECS instances by using HTTP/1.1. We recommend
that backend servers use a web server that supports HTTP/1.1.
<li class="li">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.
<section class="section" id="section-b5s-twx-wdb">
<h2 class="title sectiontitle" id="h2-url-6">Billing</h2>
<p class="p">WS and WSS protocol support is free of charge.</p>