I'm porting a net 4 library to net-core 1.0.0-preview 2
It is using Stackexchange.Redis version 1.2.1 when developing my net-core library, and 1.2.0 for the net 4 version.
In net 4, my library has never failed when calling Redis commands.
In net-core, I get this error randomly:
System.TimeoutException: Timeout performing GET netkey, inst: 6, queue: 10, qu: 0, qs: 10, qc: 0, wr: 0, wq: 0, in: 645, ar: 0, clientName: XXXXXX, serverEndpoint: Unspecified/XXXXXXX, keyHashSlot: XXXXX(Please take a look at this article for some common client-side issues that can cause timeouts: https://github.com/StackExchange/StackExchange.Redis/tree/master/Docs/Timeouts.md)
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisDatabase.StringGet(RedisKey key, CommandFlags flags)
UPDATE I'm using default configurations (connection timeout, connection retry, etc)
UPDATE Added keep-alive configuration but still failing
Any ideas?
Redis client uses a single TCP connection and can only read one response at a time. Even when a first operation times out, it does not stop the data being sent to/from the server. Because of this, it blocks other requests and causes timeouts.
To set an expiration time for an existing key in Redis, use the EXPIRE command. This command takes the key and the duration in seconds to assign to the specified key. The following examples illustrate how to use the EXPIRE command in Redis. The command above will create a new key and value.
Azure Cache for Redis service configures a 10 minute idle server timeout for connections, independently of the client library used. This is defined on Server side and cannot be changed.
The ConnectionMultiplexer is the main arbiter of the connection to Redis inside the CLR, your application should maintain a single instance of the ConnectionMultiplexer throughout its runtime. You can initialize the Multiplexer with either a connection string, or with a ConfigurationOptions object.
Updated SyncTimeout is not a good option because your redis command is runing very slow The reason of timeout is .net-core default threads count in threadpool is too low.
Just set maxThreads in environment variable.
ex:
ComPlus_ThreadPool_ForceMaxWorkerThreads 1000 ComPlus_ThreadPool_ForceMinWorkerThreads 50
Then run app in administrator identity(allow app read system environment variable)
It works to me
Solution: Updated SyncTimeout configuration to 10000. Tried with 5000 and failed, then with 10000 and fixed. Default value was 1000.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With