【发布时间】:2017-12-08 11:08:28
【问题描述】:
我正在尝试使用他们网站上提供的示例代码从 Azure 外部连接到 Azure Redis 缓存服务
boolean useSsl = false;
/* In this line, replace <name> with your cache name: */
JedisShardInfo shardInfo = new JedisShardInfo("HOST_NAME", 6379, useSsl);
shardInfo.setPassword(ACCESS_KEY); /* Use your access key. */
shardInfo.setConnectionTimeout(999999);
shardInfo.setSoTimeout(999999);
Jedis jedis = new Jedis(shardInfo);
jedis.set("foo", "bar");
String value = jedis.get("foo");
我在从 Azure 外部执行程序时遇到以下异常
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Software caused connection abort: recv failed
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:202)
at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40)
at redis.clients.jedis.Protocol.process(Protocol.java:151)
at redis.clients.jedis.Protocol.read(Protocol.java:215)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:239)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:96)
at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
at redis.clients.jedis.BinaryClient.set(BinaryClient.java:110)
at redis.clients.jedis.Client.set(Client.java:47)
at redis.clients.jedis.Jedis.set(Jedis.java:120)
at com.oriental.redis.cache.TestClient.main(TestClient.java:65)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:196)
... 11 more
该错误表明 Azure Redis 服务器从未确认连接。 我使用的是基本 Azure 订阅,因此没有创建任何高级实例,文档说防火墙/IP 访问过滤器仅适用于高级版本的 Azure Redis 缓存。
这让我很困惑。任何帮助将不胜感激。
【问题讨论】:
标签: java azure caching azure-redis-cache