You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When client web socket connection fails to switch protocols, e.g. due to 401, 403, 429, or 500 errors, the client may want to know the details of the server response status code.
try{varsocket=new ClientWebSocket();await socket.ConnectAsync(uri, cancellation);}catch(WebSocketExceptionwse)when(wse.WebSocketErrorCode == WebSocketError.NotAWebSocket){
Console.WriteLine($"Couldn't connect to web socket service. Status code: {wse.ResponseStatusCode}");}
Alternative Designs
Use WebSocketException constructors with nativeError and pass in the response status code as native error. The downside is that the native error is expected to be an HResult, not an HTTP response status code.
Risks
Low risks.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
Issue Details
Background and motivation
When client web socket connection fails to switch protocols, e.g. due to 401, 403, 429, or 500 errors, the client may want to know the details of the server response status code.
try{varsocket=new ClientWebSocket();await socket.ConnectAsync(uri, cancellation);}catch(WebSocketExceptionwse)when(wse.WebSocketErrorCode == WebSocketError.NotAWebSocket){
Console.WriteLine($"Couldn't connect to web socket service. Status code: {wse.ResponseStatusCode}");}
Alternative Designs
Use WebSocketException constructors with nativeError and pass in the response status code as native error. The downside is that the native error is expected to be an HResult, not an HTTP response status code.
Background and motivation
When client web socket connection fails to switch protocols, e.g. due to 401, 403, 429, or 500 errors, the client may want to know the details of the server response status code.
API Proposal
API Usage
Alternative Designs
Use
WebSocketException
constructors withnativeError
and pass in the response status code as native error. The downside is that the native error is expected to be an HResult, not an HTTP response status code.Risks
Low risks.
The text was updated successfully, but these errors were encountered: