Updated on 2024-10-11 GMT+08:00

WebSocket

If you have added whole site acceleration domain names to CDN to meet requirements such as on-screen commenting, collaborative session, market data broadcast, sports live update, online education, and IoT connectivity, you can configure WebSocket to implement long-term bidirectional data transmission.

Background

WebSocket is a protocol providing full-duplex communication channels over a single TCP connection. It allows a server to proactively push data to clients, simplifying data exchange between the clients and server. A persistent connection can be established between a browser and the server after one handshake and bidirectional data transmission can be performed, saving server resources and bandwidth.

Precautions

  • This function applies only to domain names whose service type is whole site acceleration and whose resources are not cached on CDN PoPs. That is, the cache TTL in cache rules of the resources is set to 0.
  • This function is in OBT and is available for free trial.
  • The maximum timeout interval is 300 seconds. If no message is transferred within the specified interval, the connection is closed.
  • You cannot configure WebSocket for domain names with special configurations.
  • Do not enable both WebSocket and HTTP/2. Otherwise, your domain name cannot be accessed.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Advanced Settings tab.
  5. In the WebSocket Settings area, click Edit.
    Figure 1 WebSocket Settings
  6. Enable Status, set a proper timeout interval (1s to 300s), and click OK.