The WebSocket protocol simplifies data exchanges between clients and servers, and allows the servers to actively push data to clients. You can enable WebSocket to reduce server resource and bandwidth usage and facilitate real-time communication. This topic describes how to enable and configure WebSocket.
- Enable WebSocket.
You must specify the billing method of WebSocket and wait until the billing method takes effect before you use WebSocket. For more information, see Activate Dynamic Route for CDN.Note
- If you are a new user, the billing method of WebSocket takes effect immediately.
- If you have used WebSocket before, the WebSocket billing method takes effect depending on the Dynamic Route for CDN (DCDN) billing method. If the DCDN uses daily billing, the WebSocket billing method takes effect at 00:00 on the next day. If DCDN uses monthly billing, the WebSocket billing method takes effect at 00:00 on the first day of the next month.
- Configure WebSocket.
- In the left-side navigation pane, click Domain Names.
- On the Domain Names page, find the target domain name and click Configure.
- In the left-side navigation pane of the specified domain, click Websocket.
- On the Websocket page, turn on Websocket.
- Click Modify.
- Set the Heartbeat Time and Back-to-Origin Protocol parameters.
Parameter Description Heartbeat Time
Heartbeat time is the interval at which the client sends data packets to the server. The default value is 60 seconds.
The client sends a data packet to the server at the specified intervals to indicate the status of the client. The server returns a data packet to the client to indicate the status of the server. The client and the server uses this heartbeat mechanism to verify the availability of each other.
Back-to-Origin Protocol The protocol policy to be used when DCDN communicates with the origin over WebSocket.
DCDN uses only HTTP to communicate with the origin over WebSocket.
DCDN uses only HTTPS to communicate with the origin over WebSocket.
DCDN uses HTTP or HTTPS to communicate with the origin over WebSocket, depending on the protocol of the client request.
- Click OK.