Overview
Version
Version | New Features |
V11.0 | / |
V11.0.2 | Added a container WebSocket solution. For details, see Container WebSocket Solution. |
Introduction
This article introduces WebSocket from the following aspects.
1. Why should you set up WebSocket?
2. What will happen if you do not set up WebSocket?
3. How to set up WebSocket?
4. How to troubleshoot when WebSocket settings are not working?
Functions
WebSocket allows servers to push data to clients actively.
In the WebSocket API, a persistent connection can be created between the client and server by a single handshake to perform bidirectional data transmission.
WebSocket is mainly used for refreshing token, obtaining the status of users being kicked out, obtaining data connection editing status, and displaying platform messages, memory and CPU, and the current number of online users in the log of the platform.
WebSocket Port Configuration
Default Port
FineReport project has WebSocket port and WebSocket forwarding port configured by default.
The order of effectiveness for the two ports is not exactly the same depending on different project environments. Applications will try to listen on the two ports sequentially according to the order of effectiveness. If an application listens successfully on any one of them, it will not listen anymore.
Ports | JAR Packages | ID | Default Value | Whether Setting Multiple Values Is Supported |
WebSocket port | / | WebSocketConfig.port | ["38888", "39888"] | Supported |
WebSocket forwarding port | From 2019/11/08 | WebSocketConfig.requestPorts | 38889 | Supported |
Configuration Method
You can choose the appropriate WebSocket port configuration method according to your own project situation.
Solutions | Scenarios | Configuration Methods |
Container WebSocket Solution | Added a new container WebSocket in V11.0.2 and later versions. Without any user operation, the system can automatically use the Web container port as the WebSocket port for connection.
| Container WebSocket Solution |
Socket.IO solution | Configuring WebSocket port in a standalone environment | WebSocket Port Configuration in a Standalone Environment |
Configuring WebSocket port in a cluster environment | WebSocket Port Configuration in a Cluster Environment | |
Configuring WebSocket port in an HTTPS environment | WebSocket Port Configuration in an HTTPS Environment | |
Opening one port only to the outside | Configuring an Existing Port as the WebSocket Port |
WebSocket Connection Failed
If the WebSocket connection still fails after configuring the WebSocket port according to the method in section "Configuration Method", see the document for troubleshooting: WebSocket Connection Failed.