If your business involves scenarios such as barrage chat, interactive live streaming, social subscriptions, collaborative sessions, multiplayer games, market broadcast, sports live update, online education, and IoT, you can configure WebSocket in ECDN for full-site acceleration.
Feature Introduction
WebSocket is a TCP-based persistent protocol that implements full-duplex communication between the client and server and allows the server to proactively send information to the client. Before the emergence of WebSocket, to implement such duplex communication, web applications needed to continuously send HTTP request calls for inquiry, which increased service costs and reduced efficiency. WebSocket has the advantage of full-duplex communication, where the client and server only need to complete a handshake to create a persistent connection and achieve bidirectional data transmission, better saving server resources and bandwidth, and enabling more real-time communication.
Notes
1. WebSocket is a feature of ECDN full-site acceleration. Before configuring WebSocket, please select an ECDN full-site acceleration domain.
2. WebSocket is a dynamic resource that does not require any caching rules and needs the origin server to support WebSocket.
3. The maximum timeout configuration for WebSocket can be set to 300s. If there is no message passing within the configured time, the default close connection will occur.
2. Click Domain Management in the left menu to enter the domain management list;
3. Select the ECDN full-site acceleration domain name to be configured, click manage and enter the domain configuration page.
4. Click Advanced Configuration, find the WebSocket timeout configuration, and you can enable WebSocket;
5. After enabling WebSocket, you can customize the timeout duration within 0-300s.
Recommended Configuration
WebSocket is a session connection established between the client and the origin server. It is recommended to configure the WebSocket timeout according to your heartbeat mechanism. If your WebSocket does not have a heartbeat mechanism, it is recommended to set the WebSocket timeout to 60s.
Configuration limitations
WebSocket timeout configuration is only supported for ECDN full-site acceleration domains. If your domain does not belong to an ECDN full-site acceleration domain (acceleration type is ECDN dynamic and static acceleration or ECDN dynamic acceleration), your domain will not be able to configure WebSocket.
Configuration Example
Sample 1
If WebSocket is in closed status, the WebSocket timeout configuration for the domain cloud.tencent.com is as follows:
cloud.tencent.com does not support WebSocket protocol. If there are WebSocket requests, the connection is easily disconnected or failed.
Sample 2
If WebSocket is in enable status and the timeout configuration is 100s, the WebSocket timeout configuration for the domain cloud.tencent.com is as follows:
cloud.tencent.com supports WebSocket protocol. The session persistence time of the protocol follows the WebSocket timeout configuration of 100s. If there is no communication request for more than 100s, the connection will be disconnected.