javascript - Is there a way to implement HTTP long connection through JS on the client side
高洛峰
高洛峰 2017-05-19 10:30:44
0
7
535

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)

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(7)
伊谢尔伦

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.

curl -Iv http://www.baidu.com 2>&1 | grep -i 'connection #0'

When the long connection is normal, the following output will be displayed

* Connection #0 to host www.baidu.com left intact

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template