Rancher Desktop and Hangfire.Pro.Redis

We’re a paying customer.

We are switching from Docker Desktop to Rancher Desktop due to ongoing issues with M1 compatibility. I am currently porting our developer machine container setup to RD, and I am having problems with the combination of RD and Hangfire.Pro.Redis.

My experiments to get this working include --bind 0.0.0.0, as well as --protected-mode off for the Redis container (even though these are the defaults). Using redis-cli, I am able to interact with the database in a variety of ways; however, Hangfire.Pro.Rails fails with either ConnectTimeout or ConnectionRefused. I have tried Redis 5 and 6.

Enabling --loglevel debug on the Redis container shows that Redis is definitely accepting connections from Hangfire.Pro.Redis.

Here is an example stack trace:

Hangfire.Pro.Redis.RedisStorageException
Connection to Redis isn't available yet, reconnect is in progress: It was not possible to connect to the redis server(s); Connection refused. Configured endpoints: localhost:6379
   at Hangfire.Pro.Redis.RedisStorage.GetMultiplexer()
   at Hangfire.Pro.Redis.RedisStorage.GetDatabase()
   at Hangfire.Pro.Redis.RedisDistributedLock.TryAcquireLock()
   at Hangfire.Pro.Redis.RedisDistributedLock.AcquireOrThrow(TimeSpan timeout)
   at Hangfire.Pro.Redis.RedisDistributedLock..ctor(Func`1 databaseFactory, Func`1 subscriverFactory, Func`2 isActiveFunc, ILockExtender lockExtender, RedisStorageOptions options, String resource, String lockToken, TimeSpan timeout)
   at Hangfire.Pro.Redis.RedisConnection.DistributedLockWrapper..ctor(RedisConnection connection, String resource, TimeSpan timeout)
   at Hangfire.Pro.Redis.RedisConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
   at Hangfire.RecurringJobExtensions.AcquireDistributedRecurringJobLock(IStorageConnection connection, String recurringJobId, TimeSpan timeout)
   at Hangfire.RecurringJobManager.AddOrUpdate(String recurringJobId, Job job, String cronExpression, RecurringJobOptions options)
   at Hangfire.RecurringJobManagerExtensions.AddOrUpdate(IRecurringJobManager manager, String recurringJobId, Job job, String cronExpression, TimeZoneInfo timeZone, String queue)
   at Hangfire.RecurringJobManagerExtensions.AddOrUpdate(IRecurringJobManager manager, String recurringJobId, Job job, String cronExpression, TimeZoneInfo timeZone)
   at Hangfire.RecurringJobManagerExtensions.AddOrUpdate(IRecurringJobManager manager, String recurringJobId, Job job, String cronExpression)

This might be caused by the endpoint name. Try using ‘127.0.0.1’ as an endpoint explicitly instead of ‘localhost’ (default one).

Thanks, that worked.

1 Like