WebSocket similar to the HTTP protocol, is to compensate for the HTTP protocol flaw: Communication can only be initiated by the client, the HTTP protocol does not make the server actively push information to the client.
The WebSocket agreement was born in 2008 and became an international standard in 2011. All browsers are already supported.
Its biggest feature is that the server can proactively push information to the client, the client can also actively send information to the server, is a true two-way equality dialogue, is a server push technology.
Other features include:
(1) based on the TCP protocol, the server-side implementation is relatively easy.
(2) Good compatibility with HTTP protocol. The default port is also 80 and 443, and the handshake phase uses the HTTP protocol, so the handshake is not easy to block, through a variety of HTTP proxy server.
(3) The data format is lighter, the performance overhead is small, and the communication is efficient.
(4) You can send text, or you can send binary data.
(5) The client can communicate with any server without the same origin limitation.
(6) The protocol identifier is WS (or WSS if encrypted) and the server URL is the URL.
ws://example.com:80/some/path
Usage method (client, server side): http://www.ruanyifeng.com/blog/2017/05/websocket.html
For low-end browsers that do not support websocket, there are typically several solutions
Implementation of Pseudo-websocket communication using polling or long connections
Implement a WebSocket client using Flash or another method: https://segmentfault.com/q/1010000005000671/a-1020000005003936
- 17532465
Article Source: http://www.ruanyifeng.com/blog/2017/05/websocket.html
WebSocket explanation and how to be compatible with low-version browsers