Skip to content

Instantly share code, notes, and snippets.

@redsquare
Created March 1, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redsquare/1ceecccb20d11731aefb20ff956e9a90 to your computer and use it in GitHub Desktop.
Save redsquare/1ceecccb20d11731aefb20ff956e9a90 to your computer and use it in GitHub Desktop.
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