mustafa
mustafa

Reputation: 3905

Signalr "No Connection with that ID" error from ASP.NET application on IIS

I have an ASP.NET & Angular application running on IIS on Windows Server 2019. After I moved the application to another server, I started receiving "No Connection with that ID" errors, so some critical functionality of the application is not working.

Interestingly, it happens after some time. When I log in, it works well in the beginning. After a few minutes, I start seeing 404 errors in the console. And, when I try going that link(https://mywebsite.com/api/Hubs/ReservationHub?id=xxx) directly on my browser, I get "No Connection with that ID".

I don't see any error logs in the server. Cloudflare is used for DNS.

Any help is appreciated.

Upvotes: 1

Views: 2664

Answers (3)

Ion Ursachi
Ion Ursachi

Reputation: 41

I was facing the same error, but everything was on the same machine/server.

The reason was hostingModel="outofprocess" (web.config). After changing inprocess the problem went away.

Upvotes: 0

Barnebyte
Barnebyte

Reputation: 161

I think you need to enable WebSockets in IIS:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-6.0

The URL you see in console should be wss://mywebsite.com/api/Hubs/ReservationHub?id=xxx

Upvotes: 1

Indrit Kello
Indrit Kello

Reputation: 1313

It looks like session persistence is not enabled or not working correctly. It is also called session affinity | "sticky" sessions.

This is to ensure that requests for the same user always go to the same server. SignalR requires that all requests for a single connection go to the same physical server. If any request ends up getting routed to a different server, you'll get a 404 "No Connection with that ID".

You can get the network trace of failed connections to get a better overview, but this is the cause most of the times.

Upvotes: 1

Related Questions