尝试使用 StackExchange.Redis 连接到 AWS Elasticache 时出错
我正在为 Redis 使用 AWS Elasticache。它配置为启用集群模式。引擎版本为6.2.6.
下面的代码示例从完全相同的机器运行,具有所需的所有权限、证书和路由/网络/acl 规则。
让我从以下一小段 python 代码开始:
fromt redis.cluster     import RedisCluster
rc = RedisCluster(host="myhost.mydomain.internal", ssl=True, passowrd="mysupersecretpassword")
rc.ping()有效并返回
True.
在我试图用来做几乎相同事情的 csharp 代码下面:
using StackExchange.Redis;
    using System.Net;
    using System.Threading.Tasks;
    namespace CSharpRedisCli
{
        class Program
    {
            static     readonly ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(
                new ConfigurationOptions{
                EndPoints = {     new DnsEndPoint("myhost.mydomain.internal", 6379) },
                ResolveDns = true,
                Ssl = true,
                Password = "mysupersecretpassword",
                AbortOnConnectFail=false
            });
        
            static     async Task Main(string[] args)
        {
                var db = redis.GetDatabase();
                var pong =     await但比我在以下问题中运行:
Unhandled exception. StackExchange.Redis.RedisConnectionException: The message timed out in the backlog attempting to send because no connection became available - Last Connection Exception: AuthenticationFailure on myhost.mydomain.internal:6379/Interactive, Initializing/NotStarted, last: NONE, origin: ConnectedAsync, outstanding: 0, last-read: 7s ago, last-write: 7s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 7s ago, v: 2.6.104.40210, command=PING, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Initializing, in: 0, last-in: 0, cur-in: 0, sync-ops: 0, async-ops: 1, serverEndpoint: myhost.mydomain.internal:6379, conn-sec: n/a, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: C02FJ1DMMD6Q(SE.Redis-v2.6.104.40210), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=0,Free=32767,Min=16,Max=32767), POOL: (Threads=6,QueuedItems=0,CompletedItems=174), v: 2.6.104.40210 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
 ---> StackExchange.Redis.RedisConnectionException: AuthenticationFailure on myhost.mydomain.internal:6379/Interactive, Initializing/NotStarted, last: NONE, origin: ConnectedAsync, outstanding: 0, last-read: 7s ago, last-write: 7s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 7s ago, v: 2.6.104.40210
 ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
   at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
   at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
   at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions)
   at StackExchange.Redis.ExtensionMethods.AuthenticateAsClientUsingDefaultProtocols(SslStream ssl, String host) in /_/src/StackExchange.Redis/ExtensionMethods.cs:line 206
   at StackExchange.Redis.ExtensionMethods.AuthenticateAsClient(SslStream ssl, String host, Nullable`1 allowedProtocols, Boolean checkCertificateRevocation) in /_/src/StackExchange.Redis/ExtensionMethods.cs:line 196
   at StackExchange.Redis.PhysicalConnection.ConnectedAsync(Socket socket, LogProxy log, SocketManager manager) in /_/src/StackExchange.Redis/PhysicalConnection.cs:line 1500
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at CSharpRedisCli.Program.Main(String[] args) in Program.cs:line 21
   at CSharpRedisCli.Program.<Main>(String[] args)我的 csharp 代码缺少什么?
编辑
主机
myhost.mydomain.    internal是指向 Elasticache 配置端点的 route53 CNAME 记录。
直接调用配置端点时有效。
调用route53主机时出现异常。虽然我的 python 代码能够处理这个调用,但需要在 dotnet/stackexchanghe.redis 端配置一些东西。
        c#
      
        redis
      
        赞
        
 收藏 0
 回答 1
 
        待解决
        
相关问题
 如何使用带有vertx的java重新连接到redis? 
4221浏览  • 1回复 待解决
尝试从 nuxt 3 中间件连接到 redis 客户端,但连接未定义是什么原因呢? 
4244浏览  • 1回复 待解决
如何使用ssl连接到PolarDB ? 
4663浏览  • 1回复 待解决
连接到数据库REDIS的Svelte自定义商店。 
3070浏览  • 1回复 待解决
telnet 命令为什么能连接到远端mysql或者redis呢? 
3406浏览  • 1回复 待解决
HarmonyOS 支持根据ssid等信息连接到指定wifi吗 
1006浏览  • 1回复 待解决
HarmonyOS 获取当前设备是否能够连接到网络的API 
1099浏览  • 1回复 待解决
golang redis客户端连接状态 
4224浏览  • 1回复 待解决
springboot 中使用 redis 并发 500 时线程错误 
8998浏览  • 1回复 待解决
docker容器内的MySQL、Redis无法连接 
4366浏览  • 1回复 待解决
在php-fpm环境中,为什么不建议使用mysql长连接,而却允许redis长连接? 
4552浏览  • 1回复 待解决
要连接 polardb 和 redis 需要进行哪些配置? 
4346浏览  • 1回复 待解决
ServiceStack.Redis连接池问题求教各位大佬 
3907浏览  • 1回复 待解决
springboot 与 redis 连接,无法启动项目的问题 
6157浏览  • 1回复 待解决
连接无密码wifi时怎么设置使用固定mac? 
7001浏览  • 1回复 待解决
编译ipcamera_hispark_taurus时出错,求解决 
8247浏览  • 1回复 已解决
Hi3861开发板串口连接到PC串口无法正常识别,如何解决? 
13883浏览  • 1回复 待解决
nginx反向代理时出错提示504什么原因? 
3433浏览  • 1回复 待解决
#鸿蒙通关秘籍#连接ServiceExtensionAbility时,如何确保连接成功? 
1088浏览  • 1回复 待解决
尝试获取Har context,app crash 
2747浏览  • 1回复 待解决
aws的ALB支持重写吗?不支持的话要怎么解决呢?目前使用EKS 
4238浏览  • 0回复 待解决
你愿意尝试华为「鸿蒙」系统吗? 
12120浏览  • 6回复 待解决
HarmonyOS 使用ffmpeg将视频转换为gif出错 
963浏览  • 1回复 待解决
编译hi3861源码时出错,润和的那块板子 
8291浏览  • 1回复 待解决





















使用与redis端点配置不同的
时,需要设置SslHost配置选项。
基于此,我编写了一个代码来从我的 R53 记录中查询 redis 端点:
我仍然需要弄清楚 Python 库如何处理这个问题,看看是否可以对 StackExchange.Redis 库做同样的事情。