Persistent ascending connections like Comet

There are many ways to have persistent downstream connections. For example, you can use a hidden iframe; or a complex XHR model that uses onreadystate to transfer partial information through your application while maintaining a connection. However, I could not find a way to make a steady upward flow in the same spirit.

If you use Connection: Keep-Alive in your upstream sense, you will not actually disconnect or rebuild each time; it's good. You can even encode your upstream in a GET request that returns an empty document

However, even though it is closed, you still do not have enough performance, low latency, and bandwidth that you can get with long, constant connections downstream.

If not, then there is another way to do this.

Here are some theories about what this type of solution will look like;

  • Perhaps the ability to send a stream mixed/multipart to the server with the boundary conditions.
  • It may be possible to transmit with subsequent transmission, with each subsequent fragment representing new data.

It is worth noting that, although this is possible with HTML5 or Flash, it would be extremely useful if you could disable it without the plug-ins in the ecosystem of browsers that are visible today. One of my aspirations is an experiment that allows me to smoothly implement Knuth coroutines between client and server.

Anyone have an idea about this? Thanks.

~ Chris.

+4
source share
1 answer

The only way to make a β€œreal” bidirectional connection in a web browser is with WebSockets. This is their main advantage - you can perform both upstream and downstream communications without the overhead of HTTP.

If your downstream connection comes with a long poll, your upstream connection will be a regular old HTTP request.

However, if you do not have MANY requests, I would think if you are trying to optimize something that really does not need optimization. Even the smallest servers available today are more than capable of handling thousands of HTTP requests per second. And since most client applications listen more in real time than they send, they quickly write to downstream connections, which really affect server performance. On the upstream side, if you use "Connection: Keep-Alive" to avoid the overhead of installing / disconnecting a socket, most applications will see a slight performance advantage by switching to WebSockets.

(I work for a company that builds WebSync .)

+2
source

Source: https://habr.com/ru/post/1339418/


All Articles