> For most apps just use SSE and the built-in code for making HTTP requests (Fetch) instead of hacking up your own client side JS to make requests over a WebSocket.
HTTP doesn't guarantee in-order delivery. Websocket messages do. In-order delivery is important for stateful protocols. For example, you can start a connection by authenticating, then associate the user with the TCP (or websocket) session. Video games often push this way futher. For example, if you log in to a minecraft server, your in-game character is associated with the TCP session.
If you use HTTP fetch requests, you can't guarantee that - for example - the authentication request will reach the server before authenticated messages.
Had a problem with this recently. Switched from Websockets to SSE and then couldnt understand why messages were coming out of order. Had to implement microtime timestamps on each sent message and then perform a check on the client to disregard any messages with older timestamps than the max currently seen for that entity.
Nothing I read anywhere on the setup and testing told me that SSE events were not guaranteed in order. I may have been blind, but I spent a week researching testing and setting it up in a live environment. You would have thought I would see something in that time!
Events sent over an sse stream should be in order. It’s a single tcp stream with messages separated by newlines. If you’re seeing messages arrive out of order, there may be a bug in whatever sse stream library you’re using.
Http messages of course have no ordering guarantee. If you want ordering (and connection state), websockets might be a better choice.
HTTP doesn't guarantee in-order delivery. Websocket messages do. In-order delivery is important for stateful protocols. For example, you can start a connection by authenticating, then associate the user with the TCP (or websocket) session. Video games often push this way futher. For example, if you log in to a minecraft server, your in-game character is associated with the TCP session.
If you use HTTP fetch requests, you can't guarantee that - for example - the authentication request will reach the server before authenticated messages.