As mentioned in the title, I need to frequently request data from a specific server and keep establishing connection requests. This will have a lot of overhead. I wonder if there is a way for JS to implement HTTP long connections and subsequent data requests. Just keep reusing this connection channel? (ignore websocket)
websocket.io
http1.1 has keep-alive turned on by default. The connection will not be closed unless the server actively writes connection-close to the header. So your worries are unnecessary.
You can check whether keep-alive is normal through the CRUL command.
When the long connection is normal, the following output will be displayed
Connection... left intact means that the server has not closed the connection and the client can reuse the connection.
If you don’t want to use websocket, use long polling.
The amount of messages is generally sufficient using websocket. If you want high-end, you can consider Alibaba’s open source RocketMQ
websockt ?
Use websocket
websocket