Long polling vs websocket while waiting for a single response from the server

I read a lot of articles about real-time push notifications. And the summary is that websocket is usually the preferred method unless you are 100% concerned about browser compatibility. And yet, one article claims that

Long polling - it is possible when you exchange one call using the server and the server does some work in the background.

This is definitely my business. The user presses a button that initiates some complex calculations on the server side, and as soon as the response is ready, the server sends a push notification to the client. The question is, can we say that for the case of one-time answers, a long survey is a better choice than websockets? Or, if we are not worried about supporting legacy browsers, and if I'm going to start a project from scratch, websockets should ALWAYS be preferable to a long poll when it comes to push protocol?

+1
source share
2 answers

The question is, can we say that for the case of one-time answers, a lengthy survey is a better choice than websockets?

. ( , ), , .


, . .

5-10 , HTTP- , , , . (- ..) http- . , . , , , .

, , , , , .

1:

  • , push-.
  • http- . , .
  • push- .
  • webSocket ( ).

2:

  • http- . , , , - taskID, .
  • http " " "" . , , "-" , .

3:

  • webSocket.
  • webSocket, .
  • , .
  • webSocket ( , ).

4:

  • , 3, socket.io webSocket, , , .

, 3 4, , . TCP- , push, .

1, , , , , HTTP- webSocket. , . 2 , ( ), .

+7

, .

-.

API Push - , , , - . , , .

  • ,
  • , SSL/HTTPS
  • Blink/Firefox atm
0

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


All Articles