ajax long connection

What is reverse ajax?

Inverting AJAX is essentially a concept: data that can be sent from the server to the client. In a standard HTTP Ajax request, data is sent to the server so that the server can send events to the client (low latency communication).

Comet

Schematic:
write picture description here

Comet using HTTP streaming

Code Demo
Client:
write picture description here
Server:
write picture description here
write picture description here

Comet using HTTP long polling

Long polling mode involves techniques that open a connection. The connection is kept open by the server, and, as long as the event occurs, the response promises and closes the connection. Then, a new long-polling connection is reopened immediately, waiting for new events to arrive at the client.

Code Demo
Client:
write picture description here
Server:
write picture description here
write picture description here

In general, Comet with Ajax long-pollin is a good compromise to satisfy:
low latency communication timeouts and error detection;
simplicity;
good support for all browsers and platforms; support for
common containers.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482736&siteId=291194637