I have an ASP.NET Core application that uses SignalR for some functions. Server-side, the Hub is configured like this:
public class MyHub : Hub
{
// ...
}
Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseSession();
app.UseSignalR(c =>
{
c.MapHub<MyHub>("/MyHub");
});
app.UseMvcWithDefaultRoute();
}
And in Client-side JavaScript:
const connection = new signalR.HubConnectionBuilder()
.withUrl("/MyHub")
.build();
connection.start()
.then(() => console.log("Connected"));
This works fine in Edge (Original UWP), Chrome, and Firefox. The connection starts immediately:
[2019-08-16T16:43:05.157Z] Information: Normalizing '/MyHub' to 'http://localhost:50519/MyHub'. signalr.js (2684,21)
[2019-08-16T16:43:05.653Z] Information: WebSocket connected to ws://localhost:50519/MyHub?id=VT-bp5j-PHa2seOpBAYQzA. signalr.js (2684,21)
Connected
In the new Edge Dev (Chromium based) browser, this happens:
[2019-08-16T16:44:30.658Z] Information: Normalizing '/MyHub' to 'http://localhost:50519/MyHub'. WebSocketTransport.ts:64 WebSocket connection to 'ws://localhost:50519/MyHub?id=j9zaJhpUPqB75G8o4n-u9Q' failed: WebSocket opening handshake timed out (anonymous) @ WebSocketTransport.ts:64 Utils.ts:179
[2019-08-16T16:48:30.904Z] Error: Failed to start the transport 'WebSockets': null ConsoleLogger.log @ Utils.ts:179 (anonymous) @ HttpConnection.ts:287 step @ HttpConnection.ts:2 (anonymous) @ HttpConnection.ts:2 rejected @ HttpConnection.ts:2 Utils.ts:185
[2019-08-16T16:48:30.962Z] Information: SSE connected to http://localhost:50519/MyHub?id=OA5D0tqwYF7Nx5AK5kouhA
Connected
Notice the time stamps. It times out and errors after four minutes attempting a WebSockets connection, but then falls back to SSE and the communication works as it should.
I know this is a pre-release browser but I've had this issue ever since I started using it several months ago and it hasn't changed. I haven't been able to find any known issues related to it so I realize it could be an issue with my application.
Update: After further testing I've found out that this only happens if Windows Authentication is enabled (and Anonymous Authentication disabled). Possibly related to: SignalR not working with Windows-integrated authentication