websockets icon indicating copy to clipboard operation
websockets copied to clipboard

Give hints about HTTP/2 and HTTP/3 support when opening a WebSocket

Open ddragana opened this issue 3 years ago • 3 comments

WebSockets over HTTP/2 are not supported by many servers. There can be different reasons for that. Support for WebSockets over HTTP/3 is a new IETF draft.

The clients do not know if WebSockets are supported by a HTTP/2 or HTTP/3 server until the TLS handshake is done and SETTINGS frames are exchange. If WebSockets are not supported the clients need to fall back to HTTP/1.1 and open a new connection. This adds a delay, trying HTTP/2 and HTTP/3 would add even more delay.

An option to eliminate trying HTTP/2 and HTTP/3 is to have hint from developer when WebSocket is created whether the servers support the feature. And if they do not support the feature, the client will use HTTP/1.1 directly.

@annevk suggested to have a way to ask for a dedicated connection, that would mean use HTTP/1.1 .

@ricea and @youennf may be you have some feedback.

ddragana avatar Oct 20 '21 12:10 ddragana

We don't try WebSocket over HTTP/2 at all unless there is an existing HTTP/2 connection which has already indicated via SETTINGS that WebSocket is supported. So there is no delay, but servers may end up not getting WebSocket over HTTP/2 when they expected it.

For better predictability, I'd like to be able to use WebSocket over HTTP/2 even when there is no existing connection. Perhaps a constructor option is the best way to achieve that.

It would be nice to align with whatever WebTransport does when it adds an HTTP/2 fallback.

ricea avatar Oct 21 '21 02:10 ricea

cc @yutakahirano

annevk avatar Oct 21 '21 05:10 annevk

Hey @ddragana could you assign this to me please?

SethiVanshika avatar Jan 15 '22 07:01 SethiVanshika