C
C#4mo ago
Pan!cKk

Multi-Instance Application with SignalR and Redis as backplane

Hello :) I have an application that I want to have multi-instances of. The application communicates with the frontend via SignalR for various use-cases, but when I launch another instance of the application, the client often fails to connect to the SignalR Hub. This is how I set Redis as the backplane:
services.AddSignalR()
.AddStackExchangeRedis(builder.Configuration.GetValue<string>("SignalR:RedisBackbone"),
options =>
{
options.Configuration.ChannelPrefix = redisChannel.Literal("Some:Prefix");
});
services.AddSignalR()
.AddStackExchangeRedis(builder.Configuration.GetValue<string>("SignalR:RedisBackbone"),
options =>
{
options.Configuration.ChannelPrefix = redisChannel.Literal("Some:Prefix");
});
With a single instance it works perfectly fine, but when another instance is introduced, it fails to connect (not always, but quite often). This is the error I get on the client side:
Unable to connect to the server with any of the available transports. Error: WebSockets failed: Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled. Error: ServerSentEvents failed: Error: EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled. Error: LongPolling failed: Error: No Connection with that ID: Status code '404'
Unable to connect to the server with any of the available transports. Error: WebSockets failed: Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled. Error: ServerSentEvents failed: Error: EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled. Error: LongPolling failed: Error: No Connection with that ID: Status code '404'
I also tried using stateful-set for the deployment, but still no luck. Is there some specific configuration that needs to be set? NOTE: Redis is a single instance
1 Reply
Pan!cKk
Pan!cKk4mo ago
UPDATE I believe the fix for this was configuring sticky-sessions on the ingress of the service in kubernetes, it seems to be working now
Want results from more Discord servers?
Add your server