pull down to refresh
0 sats \ 8 replies \ @ek 12 Apr \ parent \ on: You might not need WebSockets tech
Can’t you just retry with HTTP if the stream is dropped? And you don’t have to do that with websockets?
You don’t have to parse the app-specific messages you send over websockets?
Is this not built into HTTP/2?
Can’t you just retry with HTTP if the stream is dropped? And you don’t have to do that with websockets?
No, you don't have to do that with websockets, because you rely on the tcp stack to do that. HTTP/2 connections are also tcp, of course, but they have an idle timeout, after which the socket is forcefully closed.
You can reopen the http stream, sure, but you will be dealing with a dirty close.
You don’t have to parse the app-specific messages you send over websockets?
I am not talking about parsing the content of the message, but extracting the message from the stream.
Websocket are message based, if you use a raw http stream you'll have to figure out where the message starts and where it ends.
Is this not built into HTTP/2?
Not if you abuse the protocol like that, because your application will pipe all the data through a single stream and wait for responses, you'll have implement a queue for writers, and a callback mechanism of some sort, if you want it to be efficient.
reply
reply
reply
So when you said
to make this work in real life
You didn’t mean the example of using HTTP streams instead of websockets that came at the end?
So what’s the alternative?We touched on it very briefly in the previous sections, but if we can abstract away the transmitting side of the socket and only be left with a one-way stream of data on the receiving side, we can use a much simpler communication pattern.
What did you refer to with "this" then?
The post title is "You might not need websockets." When you say "to make this work in real life", you’re either referring to the example in the article or dismissing every case in which you want to stream something in some way that is not using websockets.
What do you think the article was talking about?
reply
Ok.. i'll try once again:
This entire concept will not work reliably because servers, intermediaries and clients will drop the connection if there is no data transmission for some time. That's what i mean with "not working in real life". You'll have to send keepalive packets and do all the stuff that tcp is already doing for you.
HTTP streaming is to stream data you already have (eg. streaming a video from netflix or the feed from twitch), they are not designed for what is shown in the example, for the things i said earlier.
If you don't believe me or don't get it, I think you should look into why websockets were created in the first place.
reply