I’ve added a feature that can be enabled to throw when it detects that the Redis client is being accessed from a different thread then the thread that resolved the client from the pool which can be enabled with:
RedisConfig.AssertAccessOnlyOnSameThread = true;
This captures the Thread’s StackTrace each time the client is resolved from the pool which is very slow, so should only be enabled when debugging connection issues.
If it does detect the client is being accessed from a different thread it will throw a InvalidAccessException
with the message containing the different Thread Ids and the original StackTrace where the client was resolved from the pool. You can compare this with the StackTrace of the Exception to hopefully identify where the client is being improperly used.
This change is available in the latest v5.1.1 that’s now available on MyGet.
If you already have v5.1.1 installed you’ll need to clear your NuGet cache to download the latest version:
$ nuget locals all -clear