question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy Blazor Server Application Websocket

See original GitHub issue

I’m trying to proxy a Blazor Server Application. I have managed to proxy the initial page load and retrieve all static files. I cannot get the SignalR websocket connection to establish. Is this supported? The Websocket proxy definition is never triggered and I get 502 error codes on the _blazor?id=XXX websocket request

I have the following config:

app.UseProxies(proxies =>
{
    // SignalR Connection
    proxies.Map("ui/_blazor", proxy => proxy.UseWs((context, args) =>
        {
            var queryString = context.Request.QueryString;
            return $"{proxyUrl}/{args["endpoint"]}{queryString}";
        }));
    // Fallback
    proxies.Map("ui/{*endpoint}", proxy => proxy.UseHttp(
        (context, args) =>
        {
            var queryString = context.Request.QueryString;
            return $"{proxyUrl}/{args["endpoint"]}{queryString}";
        }, builder => builder.WithHttpClientName("proxyClient")));
});

/// services
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
    // Disable Certificate Validation
    ServerCertificateCustomValidationCallback = (_, __, ___, ____) => true,
    UseDefaultCredentials = true
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
twitchaxcommented, Jun 25, 2020

It looks like, in the log, that the web server is interpreting this request as an http request.

Request starting HTTP/1.1 GET https://localhost:5003/ui/_blazor?id=KfqJrgcpG8oS2kD2e7uMoA

Did you “turn on” websocket support by using app.UseWebSockets();?

0reactions
georgearnallcommented, Aug 1, 2020

Apologies for not getting back to you, I’ve been pretty busy. This might be something I will come back to in the future. For now I have switch to WebAssembly and no longer require the proxy. Thanks for your help nonetheless.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET 6 | C# | Blazor Server websocket connection failed ...
I have Blazor Server app, which is hosted on our VPS in docker, behind nginx reverse proxy. If I go to the web,...
Read more >
Blazor server-side behind a proxy issue : r/dotnet
The whole idea with Blazor Server is using websockets to transfer data. With the Blazor Server hosting model, the app is executed on...
Read more >
Host and deploy Blazor Server - ASP.NET Core
To host a Blazor app behind Apache on Linux, configure ProxyPass for HTTP and WebSockets traffic. In the following example: Kestrel server is ......
Read more >
Blazor Server side app Failed to connect via WebSockets
I have a Blazor web app that used to run fine in Azure. The latest deployment does not work. It works fine locally...
Read more >
Why does this MS Blazor App Websocket connection fail?
By default when you proxy through Cloudflare it minifies the HTML, as well as CSS / JS, and in doing so it strips...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found