-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: WebSocketException to expose the underlying HTTPResponse or the response status #62474
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and motivationWhen customers connect to the Azure Web PubSub service using Line 149 in 2cbc071
WebSocketError.NotAWebSocket which makes it hard for customers to differentiate from different scenarios. Customers have to parse the net_WebSockets_Connect101Expected string to get out the status code...
API Proposalnamespace System.Net.WebSockets
{
public sealed class WebSocketException : Win32Exception
{
public HttpResponseMessage UpgradeResponse { get; }
}
} API Usagetry {
// Start the WebSocket connection
} catch (WebSocketException e) {
if (e.UpgradeResponse.StatusCode >= 500) {
// Try reconnecting...
}
} Alternative DesignsNo response RisksNo response
|
I think the discussion about adding In particular, one comment (#911 (comment)), which explains why it should be just the
|
Triage: This will help make WebSockets apps better. Should be simple. We need to first finalize the API. |
This has been addressed by the new APIs added in #25918 (comment) (exposed status code and headers). |
Background and motivation
When customers connect to the Azure Web PubSub service using
ClientWebSocket
, there is a need to check if the connection failure is reconnectable or not. For example, if the HTTP upgrade request returns 400, this WebSocket connection is not reconnectable, while when the HTTP upgrade request returns 5xx, this might be caused by intermittent network issues and it is reconnectable. However, in the current designruntime/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs
Line 149 in 2cbc071
WebSocketError.NotAWebSocket
which makes it hard for customers to differentiate from different scenarios. Customers have to parse thenet_WebSockets_Connect101Expected
string to get out the status code...API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: