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 server and bandwidth resources 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.
If you want to enable WebSocket, submit a ticket.
- WebSocket is used only for dynamic content delivery.
Apply to use WebSocket
Apply to use WebSocket: You can submit a ticket and 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.
- 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.
- HTTP/2 is disabled.
If clients do not support HTTP/2, you must disable HTTP/2 for DCDN. Otherwise, service errors may occur. For more information, see Enable HTTP/2.
- 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.
- Optional:Turn on Dynamic Acceleration. If the feature is enabled, skip this step.
- In the left-side navigation pane of the domain name, click Acceleration Rules.
- Turn on Dynamic Acceleration.
- In the left-side navigation pane of the domain name, click Websocket and turn on Websocket.
- Click Modify.
- In the Configure WebSocket dialog box, configure the Connection Timeout Period and Back-to-Origin Protocol parameters.
Parameter Description Connection Timeout PeriodThe timeout period is the interval at which the client sends data packets to the server to synchronize the current status.
Note If the timeout period of the client is longer than that of the origin server, errors may occur.
- Default value: 60.
- Unit: seconds.
- We recommend that you set the timeout period based on the following rule: A ≤ B ≤
- A: the timeout period of the clients.
- B: the timeout period of DCDN.
- C: the timeout period of the origin server.
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.
- Click OK.
Query bandwidth usage and HTTP status codes
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.