HTML5 Server-Sent Events prototyping - ambiguous error and repeated polling?

前端 未结 8 1544
野趣味
野趣味 2020-12-03 14:44

I\'m trying to get to grips with Server-Side Events as they fit my requirements perfectly and seem like they should be simple to implement, however I can\'t get past a vague

8条回答
  •  情书的邮戳
    2020-12-03 15:14

    Server Sent Event as name suggests the data should be traveling from server to client if it has to reconnect every three seconds to retrieve data from server then it is no different than other polling mechanisms.The purpose of SSE is to alert client as soon as there is new data which client is unaware of.Since server closes connection even if header is keep-alive there is no other way than to run php script in infinite loop but with considerable thread sleep to prevent burden on server.Till now i don't see any other way out and its better than spamming server every 3 seconds for new data.

提交回复
热议问题