-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Describe the bug
When using SpaProxy
for proxying a Websocket request/server which uses the Sec-WebSocket-Protocol
header (in my case Snowpack), connecting to the server fails with: "ws failed: The WebSocket client request requested '' protocol(s), but server is only accepting 'esm-hmr' protocol(s)."
The reason for this is that the Sec-WebSocket-Protocol
header gets copied via client.Options.SetRequestHeader
, but in case the response contains the Sec-WebSocket-Protocol
header, the implementation of WebSocketHandle
checks whether the protocol had been set using client.Options.AddSubProtocol
, which obviously wasn't the case.
To Reproduce
MVC Core app:
public void Configure(IApplicationBuilder app)
{
...
app.UseSpa(spa => spa.UseProxyToSpaDevelopmentServer("http://localhost:8080"));
}
With a snowpack app listening on Port 8080. When necessary, I could create a sample repo.
Exceptions (if any)
Catched exception (SpaProxy#L246): "The WebSocket client request requested '' protocol(s), but server is only accepting 'esm-hmr' protocol(s)."
Fixed by
Further technical details
dotnet --info
.NET Core SDK (gemäß "global.json"): Version: 5.0.100-preview.5.20279.10 Commit: 8139f1b74eLaufzeitumgebung:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-preview.5.20279.10\
Host (useful for support):
Version: 5.0.0-preview.5.20278.1
Commit: 4ae4e2fe08
.NET SDKs installed:
3.1.100 [C:\Program Files\dotnet\sdk]
3.1.300 [C:\Program Files\dotnet\sdk]
3.1.400-preview-015151 [C:\Program Files\dotnet\sdk]
5.0.100-preview.5.20279.10 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.5.20279.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.5.20278.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download