Spring Boot异步JedisConnectionException读取超时

时间:2018-12-12 15:46:24

标签: spring-boot redis

我将ElastiCache Redis与异步运行的Spring Boot应用程序一起使用。异步池大小为3,最大为6。

在大多数情况下,没有例外,但是大约每天一次,我看到以下例外:

org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_131]
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_131]
at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_131]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_131]
at java.net.SocketInputStream.read(SocketInputStream.java:127) ~[na:1.8.0_131]
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]

我将Jedis的超时时间从2000年增加到10000,似乎并没有改变。

Jedis池大小默认为8,每个线程的绝对值不能超过6,所以我也不认为这是问题所在。

默认情况下,Redis不会关闭空闲连接,我将Redis超时值设置为20,但它创建了新问题。我开始看到,JedisConnectionException:流的意外结束。定期,所以我将Redis超时设置为0。

根据我的研究,我给人的印象是其他人已经看到了这个问题,但是我还没有找到解决该问题的明确方法。

谢谢。

0 个答案:

没有答案