feat: enhance WebSocket services with HTTP GET handler for certificate confirmation and increase timeout for port forwarding

This commit is contained in:
Neil Dorin 2026-06-23 16:08:42 -06:00
parent a18f7800d1
commit a732c5e08e
6 changed files with 53 additions and 5 deletions

View file

@ -196,7 +196,7 @@ public class DebugSessionRequestHandler : WebApiBaseRequestHandler
return;
}
Debug.LogMessage(LogEventLevel.Information, "No debug websocket connection within 30 seconds; removing port forward for port {0}", port);
Debug.LogMessage(LogEventLevel.Information, "No debug websocket connection within timeout; removing port forward for port {0}", port);
try
{
@ -217,7 +217,7 @@ public class DebugSessionRequestHandler : WebApiBaseRequestHandler
{
Debug.LogMessage(LogEventLevel.Warning, "Error removing port forwarding on timeout: {0}", ex.Message);
}
}, 30000);
}, 120000);
}
}

View file

@ -210,7 +210,7 @@ public class RoutingFeedbackSessionRequestHandler : WebApiBaseRequestHandler
{
Debug.LogMessage(LogEventLevel.Warning, "Error removing port forwarding on timeout: {0}", ex.Message);
}
}, 30000);
}, 120000);
}
}

View file

@ -113,6 +113,7 @@ public class RoutingFeedbackWebsocket : IKeyed
_httpsServer.SslConfiguration.ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
_httpsServer.AddWebSocketService<RoutingFeedbackClient>(_path);
_httpsServer.OnGet += HandleHttpGet;
_httpsServer.Log.Level = LogLevel.Warn;
_httpsServer.Start();
@ -338,6 +339,16 @@ public class RoutingFeedbackWebsocket : IKeyed
service.Sessions.Broadcast(message);
}
private void HandleHttpGet(object sender, HttpRequestEventArgs e)
{
var res = e.Response;
var body = System.Text.Encoding.UTF8.GetBytes(
"<html><body><h2>Certificate accepted.</h2><p>You can close this tab and return to the application.</p></body></html>");
res.ContentType = "text/html";
res.ContentLength64 = body.Length;
res.Close(body, true);
}
private static X509Certificate2 LoadCert(string certPath, string certPassword)
{
return new X509Certificate2(certPath, certPassword, X509KeyStorageFlags.EphemeralKeySet);