Pan!cKk
Pan!cKk
CC#
Created by Pan!cKk on 7/16/2024 in #help
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
2 replies
CC#
Created by Pan!cKk on 7/9/2024 in #help
Scaling Background Services !
I have a background service that uses Redis as it's main operating database. What this background service do is that on user input (start button event), I store that entity on Redis and the background service keeps fetching these entities and process them (or not) based on different conditions. What I store on Redis is a list of those entities, so when a new process is requested, a new item is added to that list, and then I fetch that list and process the items within a foreach loop. It works fine with a single instance, but I am trying to figure out a way on how to make it work with multiple instances. What I tried so far was adding an new property to that entity, "IsLocked" so when it is fetched, I set that property to "true" so the other one does not process it, and finally I set it to "false". In theory it sounded possible, but the background service is executed every 100ms, what I am assuming that the other instance fetches that list before the other one updates the "IsLocked" property. I hope I am being clear with my request, but this is my first time trying to working with multiple instances, so be gentle ! Could someone provide me with some helpful resources and tips of what could be a good solution for my case? Or even if I should use a completely different approach ! Thank you in advance :)
1 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
Is there a way to download a file in chunks (with a specified bufferSize), but not download them to local disk, but only read that chunk in memory, and then upload it to S3 storage using multiPartUpload?
20 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
Hello there! I was wondering if there is a way to return the string value (either description or name) rather than the enumeration value of an enum. Take this enum for example: public enum SourceType { SourceLink = 1, Channel = 2, Video = 3 }. When I return this model: public class Source { string Title; SourceType Type; }, I wonder if the value of the property Type can be string, the name of the enum (SourceLink, Channel or Video) or the description, rather than the integer value (1, 2, 3). Has anyone done something similar? Is that even possible?
31 replies