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
Step 2: Enable WebSocket
- Log on to the DCDN console.
- In the left-side navigation pane, click Domain Names.
- On the Configure page, find the domain name that you want to manage and click Domain Names in the Actions column.
- In the left-side navigation pane on the details page of the specified domain name, click Websocket.
- Turn on WebSocket.
- Click Modify.
- In the WebSocket dialog box, set the Heartbeat Time and Back-to-Origin Protocol parameters.
Parameter Description Heartbeat TimeThe 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 If the heartbeat time for clients is longer than that for the origin server, errors may arise.
- A: the heartbeat time for clients.
- B: the heartbeat time for DCDN.
- C: the heartbeat time for the origin server.
Back-to-Origin Protocol You can specify a protocol over which requests are redirected to the origin server based on your business requirements.
DCDN uses the same protocol (HTTP or HTTPS) as the client to redirect requests to the origin server.
DCDN redirects requests to the origin server over HTTP.
DCDN redirects requests to the origin server over HTTPS.
- Click OK.
Step 3: Query bandwidth values and HTTP status codes
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.