4 ms·
Isn't http2 basically a replacement for websockets already? It's bidirectional. Has streams. Just missing a way to create a stream in browser iirc.
by Touche 6y ago
Isn't http2 basically a replacement for websockets already? It's bidirectional. Has streams. Just missing a way to create a stream in browser iirc.
- vertex-four 6y agoThere’s some discussion around doing HTTP/2 streams (reliable, stream-based) with the fetch API (I am not certain which browsers allow for this), but note that these are only one use of WebTransport - the main thing I’m excited for is doing unreliable datagrams without bringing in an entire WebRTC stack.
- PudgePacket 6y agoNot sure if you missed it or not but QUIC is HTTP3. It has known advantages that are highly valued in domains like games as josephg has mentioned.
- Touche 6y agoYeah, but what does that have to do with what I wrote? My question is, if HTTP can now do streaming and all of these other useful things that you previously got with WebSockets, why do we need a WebTransport API? Why don't we just use HTTP instead?
- lxgr 6y agoTheoretically maybe, practically definitely not. HTTP is still very much geared towards request/response semantics, just sometimes serving requests you didn‘t yet know you want to make. Also, WebTransport seems to be more of an extension of the idea of WebSockets to UDP and other reliability/ordering semantics than an outright replacement.
- zamalek 6y agoOptional reliability and ordering is very important for real-time multiplayer games. Websockets doesn't support this as it uses TCP.
- Matthias247 6y agoYou are right. If browsers would expose APIs which would allow to access request and response bodies in a streaming fashion then HTTP/2 (and actually even HTTP/1.1 with chunked encoding!) can be alternatives to websockets. The remaining difference would be websockets having builtin frame delimiters and a meaning of text and binary frames - whereas with HTTP streams you would need to do that on the appliction level. Getting Streaming APIs for HTTP was planned to be part of the ReadableStream and WritableStream extensions for fetch - but I have no idea how that effort went since I last looked at it (5 years ago).
- Touche 6y agoYou can read the response body as a stream, so that part works. You can't (last I checked) write to your request body. That's the only missing piece.