Created
March 1, 2019 14:22
-
-
Save redsquare/1ceecccb20d11731aefb20ff956e9a90 to your computer and use it in GitHub Desktop.
SSL stack redis issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net.Security; | |
using System.Security.Cryptography.X509Certificates; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using StackExchange.Redis; | |
namespace ReplicateStackRedisThreadIssue | |
{ | |
class Program | |
{ | |
private static IDatabase _db; | |
static void Main(string[] args) | |
{ | |
var conn = Connection("StackRedisThreadTest.redis.cache.windows.net,password=XXxxxxxXXXXxxx,ssl=true,abortConnect=False"); | |
_db = conn.Value.GetDatabase(0); | |
for (var x = 0; x < 20; x++) | |
{ | |
ThreadPool.QueueUserWorkItem(Process); | |
} | |
Console.ReadLine(); | |
} | |
static void Process(object callback) | |
{ | |
_db.StringGet(Guid.NewGuid().ToString()); | |
} | |
private static Lazy<ConnectionMultiplexer> Connection(string connectionString) | |
{ | |
return new Lazy<ConnectionMultiplexer>(() => | |
{ | |
var options = ConfigurationOptions.Parse(connectionString); | |
options.SyncTimeout = 10000; | |
options.CertificateValidation+=(sender, certificate, chain, errors) => true; | |
var cn = ConnectionMultiplexer.Connect(options); | |
return cn; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment