dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.64k stars 25.29k forks source link

REST Middleware: Is SignalR attempting to connect for the first time or reconnect #27085

Open Dprosevski opened 2 years ago

Dprosevski commented 2 years ago

Help us make content visible

I searched for reconnection, reconnecting, reconnect, signalr, http and similar

Describe the new topic

this.hubConn = new HubConnectionBuilder().withUrl("https://server/hubEndPoint}", { skipNegotiation: true, transport: HttpTransportType.WebSockets }).withAutomaticReconnect()

When SignalR attempts to start the connection with the server using "HttpTransportType.WebSockets", it makes a "GET" call to the server to start it. My middleware intercepts the GET call and I see all the variables of the context (request, headers etc.). However on the reconnect (triggered by "withAutomaticReconnect()") SignalR makes another GET call to reconnect to the same URL it was initially built with. So my middleware on the server side intercepts it again. And that is all fine, the issue is that I see NOTHING that is telling me that this second request is made because of reconnection.

Possible solution would be to add something to Request.Headers that would tell the user if the GET call for SignalR is for connection or reconnection.

Dprosevski commented 2 years ago

@Rick-Anderson hello, what more information are you interested it?