Reputation: 1734
My application is having issues accepting the handshake about half the time in my production environment. On my local machine and in my staging environment, which is the same as production, it works every time.
It is a .Net Core 2.1 app using aspnet-signalr/1.1.4
I am not configuring SignalR to use any specifics in my startup.s
app.UseSignalR(routes => { routes.MapHub<PortfolioHub>("/loadpagedetailsjob"); });
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Dashboard}/{action=Index}/{id?}");
});
my PortfolioHub is just a direct implementation of the Hub class
and in my page
var connection = new signalR.HubConnectionBuilder()
.withUrl('/loadpagedetailsjob')
.configureLogging(signalR.LogLevel.Information)
.build();
connection.start().then(function () {
connection.invoke("Subscribe");
});
It looks like it tries to negotiate web socket then long polling and both fail. But the requests return 200
Since it is only happening sometimes I am having issues resolving the issue. My only suspicion at this point is since my environment is in AWS behind a load balance that the negotiate requests are routed to different servers which might cause the issue?
Any help is appreciated.
Upvotes: 2
Views: 3743
Reputation: 5814
SignalR requires that one connection is always handled by the same server. The typical solution is to configure the load balancer to use sticky sessions. With sticky sessions enabled, the load balancer will route requests of the same user to the same backend server.
https://learn.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-3.1
Upvotes: 2