[ACCEPTED]-What does "xhr-polling" config do in socket.io?-long-polling

Accepted answer
Score: 16

xhr-polling means that your server will 22 be waiting for 10 seconds on any GET of 21 POST received that it does not have an answer 20 before answering instead of sending back 19 an empty response. So, if your server has 18 no information to give back after 10 seconds, it 17 will answer back with an empty response. You 16 can read more here : Long polling

I personally use xhr-polling 15 as a fallback option from WebSockets in 14 an application on nodejitsu (another node 13 hosting like Heroku) and it is working fine. The 12 only thing is the "on connection" event 11 that takes about 3-8 seconds instead of 10 being instant as with my WebSocket application.

There 9 is no new connection that is created on 8 every new polling, it is just a way that 7 only one GET or POST is sent to the server 6 every 10 seconds, instead of having to poll 5 the server every .5 seconds to have a "real-time" application. If 4 the server answer in less than 10 seconds, there 3 will be another poll sent to prepare the 2 next answer.

I hope this will help you. Have 1 a good day.

Score: 4

socket.io reconnects clients automatically.

0

More Related questions