0

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

Valuator
  • 3,262
  • 2
  • 29
  • 53
  • 1
    It might be just you, but you should still create an issue for two reasons: 1) there might actually be a bug that only appears in edge case scenarios, and you might be that edge case and 2) there will be deeper knowledge of potential things in the Edge Chromium branch that could be causing issues in conjunction with your app. – Chris Pratt Aug 16 '19 at 17:18
  • @ChrisPratt I submitted feeback via the in-browser function. I don't know where else I can raise the issue. – Valuator Aug 16 '19 at 18:53
  • I tested the ASP.NET Core SignalR sample in Edge Dev(78.0.244.0) and it worked well without any error. I used the example in [this article](https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?tabs=visual-studio&view=aspnetcore-2.2). I also added your code into my sample project and it worked well too. It could be better if you share a simple sample which reproduces the issue. Besides, what's the version of the Edge Dev you using? You could update to the latested version of Edge Dev and try it again. – Yu Zhou Aug 19 '19 at 06:27
  • @YuZhou Check my latest update. Try your example in IIS Express with Windows Authentication enabled and Anonymous Authentication disabled. – Valuator Aug 19 '19 at 16:21
  • I test it with Windows Authentication enabled and Anonymous Authentication disabled. But I get the time out error only in Chrome. It works fine in Edge Dev. As you have figured out the reason why the issue occurs, you could post it as an answer. It can help other community members in future in similar kind of issues. Thanks for your understanding. – Yu Zhou Aug 20 '19 at 05:50
  • Weird, mine works in Chrome but not Edge Dev. Chrome is 76.0.389, Edge is 78.0.244. Going to close this as a duplicate since this is surely the issue. – Valuator Aug 20 '19 at 14:39
  • 1
    Possible duplicate of [SignalR not working with Windows-integrated authentication](https://stackoverflow.com/questions/44612867/signalr-not-working-with-windows-integrated-authentication) – Valuator Aug 20 '19 at 14:39

0 Answers0