3 ms·
How is http2 bidirectional streams better than websockets? I thought they were pretty much equivalent.
by nightpool 2y ago
How is http2 bidirectional streams better than websockets? I thought they were pretty much equivalent.
- 0x457 2y agoWell, IMO h2 streams are more flushed out and offer better control than websockets, but that's just my opinion. In fact, websockets are your only "proper" option if you want hat bidirectional stream be binary - browsers don't expose that portion of h2 to JS. Here is a silly thing that is possible with h2 over a single connection, but not with websockets: Multiple page components (Islands) each have their own stream of events over a single h2 connection. With websockets, you will need to roll your own multiplexing[1]. [1]: I think you can multiplex multiple websockets over a single h2 connection tho, but don't quote me on this.
- nightpool 2y agoMultiplexing websockets has always seemed trivial to me. Curious to learn more about h2 streams though! Support is coming to JS and has already landed on Firefox and Chrome: https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API https://developer.mozilla.org/en-US/docs/Web/API/WebTranspor...