The WebSocket protocol simplifies data exchange between a client and a server by allowing the server to push data to the client. WebSocket increases the utilization of resources and bandwidth of the server and reduces latency. This topic describes how to enable and configure WebSocket.

  • By default, WebSocket is disabled. After you enable the WebSocket feature, the feature is displayed in the Dynamic Route for CDN (DCDN) console.

    To enable WebSocket, submit a ticket.

  • WebSocket is incompatible with DCDN WAF and Enable HTTP/2. You cannot enable WebSocket and DCDN WAF or HTTP/2 at the same time.
  • WebSocket is used only for dynamic content delivery.

Apply to use WebSocket

Method: You can submit a ticket to apply to use WebSocket.

Only enterprise users can apply to use WebSocket. You cannot enable WebSocket for domain names whose origin servers are deployed outside the Chinese mainland and whose acceleration region is set to Mainland China Only or Global.

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, you can enable WebSocket in the DCDN console.
Notice WebSocket is a value-added feature and is billed as an independent service. For more information about WebSocket billing, see DCDN Pricing.

Enable WebSocket

Note Before you enable the WebSocket feature, make sure that your Alibaba Cloud account has passed real-name verification for enterprises, and a domain name that belongs to your Alibaba Cloud account has a valid Internet Content Provider (ICP) number.
  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. Optional: Turn on Dynamic Acceleration. If the feature is enabled, skip this step.
    1. In the left-side navigation pane of the domain name, click Acceleration Rules.
    2. Turn on Dynamic Acceleration.
      Enable dynamic content delivery
  5. In the left-side navigation pane of the domain name, click Websocket and turn on Websocket.
    Enable WebSocket
  6. Click Modify.
  7. In the Configure WebSocket dialog box, configure the Connection Timeout Period and Back-to-Origin Protocol parameters.
    Parameter Description
    Connection Timeout Period
    The timeout period is the interval at which the client sends data packets to the server to synchronize the current status.
    • Default value: 60.
    • Unit: seconds.
    • We recommend that you set the timeout period based on the following rule: A ≤ B ≤ C.
      • A: the timeout period of the clients.
      • B: the timeout period of DCDN.
      • C: the timeout period of the origin server.
    Note If the timeout period of the client is longer than that of the origin server, errors may occur.
    Back-to-Origin Protocol You can specify a protocol over which requests are redirected to the origin server.
    • Follow: DCDN uses the same protocol (HTTP or HTTPS) as the client to redirect requests to the origin server. Port 443 or 80 of the origin server must be open.
    • HTTP: DCDN redirects requests to the origin server over HTTP.
    • HTTPS: DCDN redirects requests to the origin server over HTTPS. Port 443 of the origin server must be open.
  8. Click OK.

Query traffic and bandwidth usage and HTTP status codes

After you configure and use 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 and HTTP CODE. WebSocket monitoring

Disable WebSocket

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