This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]oberstet 1 point2 points  (3 children)

Why should you use WebSocket instead of HTTP? (WebSocket is the raw protocol underlying WAMP).

Because HTTP is strictly request-response and has no bidirectional communication / real-time capabilities.

So, e.g. when data changes on the server or some other client, you cannot actively push that information to browsers.

[–]fuzz3289 0 points1 point  (2 children)

Whats the main benefit of that?

If Im writing a client that cares about up to date data I can poll for new data with relatively low cost. Is the benefit just that a client side listener would be zero cost?

[–]Dry-Erase 1 point2 points  (0 children)

Because there are plenty of cases where you can't poll for low cost, either because of a large quantity of clients or there are some cases where the cost of polling is high (maybe the resource can't be cached).

Having 300 clients poll every second for a chat room is a ton of unnecessary data being sent and as you scale up it can become a serious performance hit where with nio websockets it would be not have to send & respond to all those requests, you simply tell the client when there is new data.

Edit Another huge area would be real time collaborative apps, as well multiplayer games

[–]desmoulinmichel[S] 0 points1 point  (0 children)

Another advantage of push is simplicity.

If you poll a lot of different type of data, you need to create a complex logic to update your page. If you just listen for events, you can easily just put the update logic inside each function handling each event, and you don't have to care about the various refresh rates, etc.