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.
2
Answers
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.
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