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:

  1. </section>
  2. <section class="section" id="section-azg-kwx-wdb">
  3. <h2 class="title sectiontitle" id="h2-url-3">How can I enable WS and WSS on Server Load Balancer?</h2>
  4. <p class="p">No configuration is required. The HTTP listener supports the WS protocol and the HTTPS
  5. listener supports WSS protocol by default.
  6. </p>
  7. <div class="p">
  8. <div class="note note note-note">
  9. <div class="note-icon-wrapper"><i class="icon-note note"></i></div>
  10. <div class="note-content"><strong>Note</strong> You must upgrade the instance to a guaranteed-performance instance.</a>.
  11. </div>
  12. </div>
  13. </div>
  14. </section>
  15. <section class="section" id="section-yts-twx-wdb">
  16. <h2 class="title sectiontitle" id="h2-url-4">Supported regions</h2>
  17. <p class="p">The WS and WSS support is available in all regions.</p>
  18. </section>
  19. <section class="section" id="section-zts-twx-wdb">
  20. <h2 class="title sectiontitle" id="h2-url-5">Limits</h2>
  21. <p class="p">The limitations for WS and WSS protocol are as follows:</p>
  22. <ul class="ul" id="ul-a5s-twx-wdb">
  23. <li class="li">Server Load Balancer is connected to backend ECS instances by using HTTP/1.1. We recommend
  24. that backend servers use a web server that supports HTTP/1.1.
  25. </li>
  26. <li class="li">If there is no message interaction between Server Load Balancer and a backend ECS
  27. instance within 60 seconds, the connection is terminated. If you need to maintain
  28. the connection, enable Keepalive to ensure message interaction at the frequency of
  29. once every 60 seconds.
  30. </li>
  31. </ul>
  32. </section>
  33. <section class="section" id="section-b5s-twx-wdb">
  34. <h2 class="title sectiontitle" id="h2-url-6">Billing</h2>
  35. <p class="p">WS and WSS protocol support is free of charge.</p>
  36. </section>
  37. </div>
  38. </article>
  39. </main>