Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SSL stack redis issue
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