Skip to content
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

[dsrouter] fix web socket startup #5121

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Microsoft.Diagnostics.WebSocketServer/WebSocketServerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,24 @@ private static void ParseWebSocketURL(string endPoint, out Uri uri)
uriToParse = endPoint;
}

string[] supportedSchemes = new string[] { "ws", "wss", "http", "https" };

if (!string.IsNullOrEmpty(uriToParse) && Uri.TryCreate(uriToParse, UriKind.Absolute, out uri))
{
bool supported = false;
foreach (string scheme in supportedSchemes)
if (uri.Scheme == "ws")
{
if (string.Equals(uri.Scheme, scheme, StringComparison.InvariantCultureIgnoreCase))
{
supported = true;
break;
}
uri = new UriBuilder(uri) { Scheme = "http" }.Uri;
return;
}
if (!supported)
if (uri.Scheme == "wss")
{
throw new ArgumentException(string.Format("Unsupported Uri schema, \"{0}\"", uri.Scheme));
uri = new UriBuilder(uri) { Scheme = "https" }.Uri;
return;
}
return;
if (uri.Scheme == "http" || uri.Scheme == "https")
{
return;
}
throw new ArgumentException(string.Format("Unsupported Uri schema, \"{0}\"", uri.Scheme));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/dotnet-dsrouter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static Option WebSocketURLAddressOption() =>
description: "The router WebSocket address using format ws://[host]:[port]/[path] or wss://[host]:[port]/[path]. " +
"Launch app with WasmExtraConfig property specifying diagnostic_options with a server connect_url")
{
Argument = new Argument<string>(name: "webSocketURI", getDefaultValue: () => "")
Argument = new Argument<string>(name: "webSocketURI", getDefaultValue: () => "ws://127.0.0.1:8088/diagnostics")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to already be set as the default value as part of WeSocketServerRouterFactory,

_webSocketURL = string.IsNullOrEmpty(webSocketURL) ? "ws://127.0.0.1:8088/diagnostics" : webSocketURL;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it also needs to flow into WebSocketServerImpl.ParseWebSocketURL otherwise it throws on empty value and continues starting silently without actually working!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me check that, sound like that parsing should be done elsewhere.

};

private static Option RuntimeTimeoutOption() =>
Expand Down