StackExchange.Redis.RedisServerException with new BackgroundJobServer

Tags: #<Tag:0x00007f065de9cd88> #<Tag:0x00007f065de9cc98>

Hello, we are using Hangfire Pro with Redis storage and when we start a new BackgroundJobServer we have the following exception (the retries never work):

2017-10-19 09:04:48,310 [8] INFO [(null)] - Starting Hangfire Server
2017-10-19 09:04:48,334 [8] INFO [(null)] - Using job storage: ‘redis://localhost:6379/1’
2017-10-19 09:04:48,344 [8] INFO [(null)] - Using the following options for Hangfire Server:
2017-10-19 09:04:48,353 [8] INFO [(null)] - Worker count: 20
2017-10-19 09:04:48,363 [8] INFO [(null)] - Listening queues: ‘dvhwbep’
2017-10-19 09:04:48,372 [8] INFO [(null)] - Shutdown timeout: 00:00:15
2017-10-19 09:04:48,382 [8] INFO [(null)] - Schedule polling interval: 00:00:15
2017-10-19 09:04:49,618 [Worker #99dab340] WARN [(null)] - Error occurred during execution of ‘Worker #99dab340’ process. Execution will be retried (attempt #3) in 00:00:07 seconds.
StackExchange.Redis.RedisServerException: ERR wrong number of arguments for ‘set’ command
à StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor1 processor, ServerEndPoint server) à StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor1 processor, ServerEndPoint server)
à StackExchange.Redis.RedisDatabase.StringSet(RedisKey key, RedisValue value, Nullable1 expiry, When when, CommandFlags flags) à StackExchange.Redis.RedisDatabase.LockTake(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags) à StackExchange.Redis.KeyspaceIsolation.DatabaseWrapper.LockTake(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags) à Hangfire.Pro.Redis.RedisDistributedLock.<.ctor>b__8_0() à Hangfire.Pro.Redis.RedisDistributedLock.RetryUntilTrue(Func1 action, Nullable1 timeOut) à Hangfire.Pro.Redis.RedisDistributedLock..ctor(Func1 databaseFactory, String resource, String lockToken, TimeSpan timeout)
à Hangfire.Pro.Redis.RedisConnection.DistributedLockWrapper…ctor(RedisConnection connection, String resource, TimeSpan timeout)
à Hangfire.Pro.Redis.RedisConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
à Hangfire.Storage.StorageConnectionExtensions.AcquireDistributedJobLock(IStorageConnection connection, String jobId, TimeSpan timeout)
à Hangfire.States.BackgroundJobStateChanger.ChangeState(StateChangeContext context)
à Hangfire.Server.Worker.Execute(BackgroundProcessContext context)
à Hangfire.Server.ServerProcessExtensions.Execute(IServerProcess process, BackgroundProcessContext context)
à Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)

2017-10-19 09:04:49,632 [Worker #bbba1fa7] WARN [(null)] - Error occurred during execution of ‘Worker #bbba1fa7’ process. Execution will be retried (attempt #3) in 00:00:05 seconds.
StackExchange.Redis.RedisServerException: ERR wrong number of arguments for ‘set’ command
à StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor1 processor, ServerEndPoint server) à StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor1 processor, ServerEndPoint server)
à StackExchange.Redis.RedisDatabase.StringSet(RedisKey key, RedisValue value, Nullable1 expiry, When when, CommandFlags flags) à StackExchange.Redis.RedisDatabase.LockTake(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags) à StackExchange.Redis.KeyspaceIsolation.DatabaseWrapper.LockTake(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags) à Hangfire.Pro.Redis.RedisDistributedLock.<.ctor>b__8_0() à Hangfire.Pro.Redis.RedisDistributedLock.RetryUntilTrue(Func1 action, Nullable1 timeOut) à Hangfire.Pro.Redis.RedisDistributedLock..ctor(Func1 databaseFactory, String resource, String lockToken, TimeSpan timeout)
à Hangfire.Pro.Redis.RedisConnection.DistributedLockWrapper…ctor(RedisConnection connection, String resource, TimeSpan timeout)
à Hangfire.Pro.Redis.RedisConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
à Hangfire.Storage.StorageConnectionExtensions.AcquireDistributedJobLock(IStorageConnection connection, String jobId, TimeSpan timeout)
à Hangfire.States.BackgroundJobStateChanger.ChangeState(StateChangeContext context)
à Hangfire.Server.Worker.Execute(BackgroundProcessContext context)
à Hangfire.Server.ServerProcessExtensions.Execute(IServerProcess process, BackgroundProcessContext context)
à Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)

Hi, what Redis version are you using and where did you get it? Such a problem may occur, when you are using Redis older than 2.6.12.

Indeed it was version 2.4.6. So you can close this one. thank you for your rapid answer!

Great, for Windows I’d recommend you to use MSOpenTech version of Redis: https://github.com/MSOpenTech/redis. However, I will not recommend it for production usage, because it’s not maintained anymore, and there were bugs. Microsoft uses their own private fork of Redis in Azure, but it’s not accessible for us.