All Products
Search
Document Center

:Configure WebSocket

Last Updated:Dec 05, 2023

The WebSocket protocol simplifies data exchange between a client and a server by allowing the server to push data to the client. WebSocket helps increase resource utilization, save your bandwidth, and reduce the latency. This topic describes how to enable and configure WebSocket.

Usage notes

  • WebSocket is incompatible with WAF and HTTP/2. You cannot enable WebSocket and WAF or HTTP/2 at the same time. Otherwise, your domain name cannot be accessed. For more information, see Overview of WAF (new version) and Enable HTTP/2.

  • WebSocket is used only for dynamic content delivery.

  • If you upgrade from Alibaba Cloud CDN to Dynamic Content Delivery Network (DCDN) for a domain name, you need to submit a ticket to change from the Alibaba Cloud CDN architecture to the DCDN architecture for the domain name before you can enable WebSocket.

Billing

WebSocket is a value-added feature and the billing of WebSocket is separated. For more information about the billing of WebSocket, visit the DCDN billing page.

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 Domain Names page, find the domain name that you want to manage and click Configure in the Actions column.

  4. (Optional) Turn on Dynamic Acceleration. If the feature is enabled, skip this step.

    1. In the left-side navigation tree of the domain name, click Acceleration Rules.

    2. Turn on Dynamic Acceleration.

      开通动态加速

  5. In the left-side navigation tree of the domain name, click Websocket and turn on Websocket.

    开启Websocket

  6. Click Modify.

  7. In the Configure WebSocket dialog box, configure the Connection Timeout Period and Back-to-Origin Protocol parameters.

    Websocket

    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, an error may occur.

    Back-to-Origin Protocol

    The 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.

Disable WebSocket

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