The WebSocket protocol simplifies data exchanges between clients and servers, and allows servers to actively push data to clients. You can enable WebSocket to minimize the usage of server and bandwidth resources, and to facilitate real-time communication. This topic describes how to enable and configure WebSocket.

Procedure

  1. Enable WebSocket.
    Before you use WebSocket, you must specify the billing method of WebSocket and wait until the billing method takes effect. For more information, see Activate the DCDN service.
    Note
    • If you are a new user, the billing method of WebSocket immediately takes effect.
    • If you have used WebSocket before, the time when the WebSocket billing method takes effect depends on the Dynamic Route for CDN (DCDN) billing method. If DCDN uses the daily billing method, the WebSocket billing method takes effect at 00:00 on the next day. If DCDN uses the monthly billing method, the WebSocket billing method takes effect at 00:00 on the first day of the next month.
  2. Configure the WebSocket protocol.
    1. In the left-side navigation pane, click WebSocket.
    2. Find the domain name that you want to manage. Then, click Modify for the domain name.
    3. Turn on Websocket.
    4. Click Modify.
    5. In the Configure WebSocket dialog box, specify the Heartbeat Time and Back-to-Origin Protocol parameters.
      Websocket
      Parameter Description
      Heartbeat Time

      The heartbeat time is the interval at which the client sends data packets to the server to indicate the status of the client. The default value is 60 seconds. We recommend that you set the heartbeat time based on the following rule: A ≤ B ≤ C.

      Note A represents the heartbeat time of the client. B represents the heartbeat time of DCDN. C represents the heartbeat time of the origin server.

      If the heartbeat time of the client is longer than that of DCDN, DCDN may be disconnected when the client is active. This results in service errors. Assume that A is 80 seconds, B is 60 seconds, and C is 80 seconds. If no data is transferred at the sixty-first second or earlier, DCDN is disconnected because its 60-second heartbeat time has elapsed. If the client sends status data to DCDN at the seventieth second, a service error occurs.

      Back-to-Origin Protocol The protocol policy to be used when DCDN communicates with the origin server over WebSocket.
      • HTTP

        DCDN uses only HTTP to communicate with the origin server over WebSocket.

      • HTTPS

        DCDN uses only HTTPS to communicate with the origin server over WebSocket.

      • Follow

        DCDN uses HTTP or HTTPS to communicate with the origin server over WebSocket. The protocol that DCDN uses depends on the protocol of client requests.

    6. Click OK.