The WebSocket protocol simplifies data exchanges between clients and servers, and allows servers to proactively push data to clients. WebSocket increases the utilization of server and bandwidth resources, and implements instant communication. This topic describes how to configure WebSocket.


  • Disable HTTP/2.

    If clients do not support HTTP/2, you must disable HTTP/2 for Dynamic Route for CDN (DCDN). Otherwise, service errors may arise. For more information about how to disable HTTP/2, see Enable HTTP/2.

  • The Alibaba Cloud account has passed real-name verification for enterprises, and a domain name that belongs to the Alibaba Cloud account has an Internet Service Provider (ICP) number.

Step 1: Apply to activate WebSocket

You must submit the required information to apply to activate WebSocket. Then, Alibaba Cloud customer service reviews the application and notifies you of the result by text messages and emails within one business day. After your application is approved, the configuration page of WebSocket is displayed in the DCDN console.
Notice WebSocket is a value-added feature and is billed as an independent service. 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, see DCDN Pricing.

Step 2: Enable WebSocket

  1. Log on to the DCDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Configure page, find the domain name that you want to manage and click Domain Names in the Actions column.
  4. In the left-side navigation pane on the details page of the specified domain name, click Websocket.
  5. Turn on WebSocket.
    Enable WebSocket
  6. Click Modify.
  7. In the 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.
    • A: the heartbeat time for clients.
    • B: the heartbeat time for DCDN.
    • C: the heartbeat time for the origin server.
    Note If the heartbeat time for clients is longer than that for the origin server, errors may arise.
    Back-to-Origin Protocol You can specify a protocol over which requests are redirected to the origin server based on your business requirements.
    • Follow

      DCDN uses the same protocol (HTTP or HTTPS) as the client to redirect requests to the origin server.

    • HTTP

      DCDN redirects requests to the origin server over HTTP.

    • HTTPS

      DCDN redirects requests to the origin server over HTTPS.

  8. Click OK.

Step 3: Query bandwidth values and HTTP status codes

After you configure and enable WebSocket, click WebSocket in the left-side navigation pane in the DCDN console to go to the WebSocket page. Then, you can view monitoring information about bandwidth values and HTTP status codes. Monitor WebSocket

Step 4: Disable WebSocket

If you no longer want to use WebSocket, you can disable WebSocket in the DCDN console. After you turn off WebSocket in the DCDN console, WebSocket is immediately disabled.