-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
I've found very suspicious code while looking at ClientWebSocket, I didn't try to create a repro yet, but it should be easy to do so.
TL;DR: I suspect if you try to use WebSocket with custom security options like Credentials or RemoteCertificateValidationCallback, it will result in premature HTTP/2 connection disposal, so the WebSocket will not be usable.
The code that decides whether WS should dispose the message handler after use does that regardless of HTTP version
Lines 240 to 247 in 3824cb2
if (options.Credentials == null && | |
!options.UseDefaultCredentials && | |
options.Proxy == null && | |
options.Cookies == null && | |
options.RemoteCertificateValidationCallback == null && | |
(options._clientCertificates?.Count ?? 0) == 0) | |
{ | |
disposeHandler = false; |
Lines 264 to 266 in 3824cb2
else | |
{ | |
disposeHandler = true; |
Disposing the handler after the Upgrage request is totally ok in HTTP/1.1 case, because the connection is removed from the HttpConnectionPool. But for HTTP/2 case, the connection stays in the pool, as only one stream is used for a WebSocket and other streams can be used for HTTP requests.
So, as the code follows, after an Extended Connect call and creation of a WebSocket, the handler will get disposed, which will result in HTTP/2 connections in the pool being disposed, which will result in a closed HTTP/2 stream and an aborted WebSocket -- unless I miss something.
Could you please check out this scenario @greenEkatherine?