microsoft / reverse-proxy

A toolkit for developing high-performance HTTP reverse proxy applications.
https://microsoft.github.io/reverse-proxy
MIT License
8.6k stars 843 forks source link

SignalR/Websockets connection negotiation with custom HTTP header does not forward such HTTP header #2603

Closed risogolo closed 1 month ago

risogolo commented 2 months ago

Describe the bug

I need to send/forward custom HTTP header during SignalR/Websockets connection negotiation, this works on my local SignalR Hub and console application (WebSockets client), but if I put Yarp in between then it does not work, the thing is that I dont see these custom added HTTP headers in incoming request (RequestTransformContext), so they are not being forwarded which is my goal.

To Reproduce

When creating SignalR client connection I am adding WithUrl like:

var connection = new HubConnectionBuilder() .WithUrl(new Uri($"{url.TrimEnd('/')}/v2/chat"), options => { options.AccessTokenProvider = accessTokenProvider; options.Headers.Add("company-id", headerProvider.GetCompanyId()); })

then in Yarp add into the HTTP request processing pipeline app.UseWebSockets();

as mentioned I dont see company-id header in incoming request in RequestTransformContext even though I have "RequestHeadersCopy": "true" in configuration

Further technical details

I am using yarp 2.1.0 Windows 11

MihaZupan commented 2 months ago

Unknown headers are copied by default when establishing WebSocket connections.

Can you create a small runnable example that reproduces the issue?

MihaZupan commented 1 month ago

Closing as this is not actionable by us at the momemnt. Feel free to reopen if/when you have more info/questions.