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 facilitate real-time communication. This topic describes how to enable and configure WebSocket.


Dynamic Route for CDN (DCDN) is activated. For more information about how to activate DCDN, see Activate DCDN.


  1. Enable WebSocket.
    To enable WebSocket, submit information. Before you submit a ticket, make sure that your Alibaba Cloud account has completed enterprise authentication. After you submit a ticket, Alibaba Cloud will manually review your application and notify you of the result by SMS and email within one day. After your application is approved, you can view the configuration page of WebSocket in the DCDN console.
    • Before you enable WebSocket, you must disable HTTP/2. Otherwise, errors may occur. For more information about how to disable HTTP/2, see Enable HTTP/2.
    • WebSocket is a value-added feature and is separately billed. When you use WebSocket, you are charged for data transfer based on the prices displayed on the pricing page. Some users are charged for bandwidth based on tiered pricing. For more information about the pricing of WebSocket, see Pricing of DCDN.
  2. Configure WebSocket.
    1. Log on to the DCDN console.
    2. In the left-side navigation pane, click Domain Names.
    3. On the Domain Names page, find the domain name that you want to manage and click Configure.
    4. In the left-side navigation pane of the page that appears, click Websocket.
    5. Turn on Websocket.
      Enable WebSocket
    6. Click Modify.
    7. In the Configure WebSocket dialog box, set the Heartbeat Time and Back-to-Origin Protocol parameters.
      Parameter Description
      Heartbeat Time

      The heartbeat time is the interval at which the client sends data packets to the server to synchronize the current status with each other. The default heartbeat time 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. For example, A is set to 80 seconds, B is 60 set to seconds, and C is set to 80 seconds. If data is transferred for the first 60 seconds but no data is transferred at the 61st second, DCDN is disconnected because its 60-second heartbeat time has timed out. If the client sends status data to DCDN at the 70th 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 the client

        DCDN uses the same protocol (HTTP or HTTPs) as that of the client to communicate with the origin server over WebSocket.

    8. Click OK.


After you configure and use WebSocket, you can go to the WebSocket page in the left-side navigation pane of the DCDN console. On the WebSocket page, you can view monitoring information about traffic and HTTP status codes. Monitor WebSocket