使用场景

报错信息

2023-03-29 10:54:38.186 ERROR 9136 --- [ntainer#7-0-C-1] c.n.r.service.IntersectionQueryService   : Exception in getIntersectionById() with cause = 'redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out' and exception = 'java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out'

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
	at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:65)
	at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:42)
	at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
	at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:187)
	at org.springframework.data.redis.connection.jedis.JedisConnection.doWithJedis(JedisConnection.java:802)
2023-08-24 09:44:23.721 ERROR 92250 --- [ns-pool-evictor] redis.clients.jedis.JedisFactory         : Error while validating pooled Jedis object.

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
	at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:205)
	at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:43)
	at redis.clients.jedis.Protocol.process(Protocol.java:162)
	at redis.clients.jedis.Protocol.read(Protocol.java:227)
	at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:352)
	at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:270)
	at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:380)
	at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:214)
	at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:745)
	at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:160)

解决方式

spring:
  redis:
    jedis:
      pool:
        min-idle: 10
        max-idle: 300  # 改大了
        max-wait: 30000  # 改大了
        max-active: 200  # 改大了
  core-app:
    image: june
    container_name: core
    volumes:
      - /etc/localtime:/etc/localtime
    depends_on:
      - postgresql
      - redis
    environment:
      - _JAVA_OPTIONS=-Xmx6G -Xms1G
      - SERVER_PORT=8181
      - SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase
      - SPRING_DATASOURCE_URL=jdbc:postgresql://postgresql:5432/core
      - SPRING_DATASOURCE_USERNAME=xxxx
      - SPRING_DATASOURCE_PASSWORD=xxxxxxx
      - SPRING_REDIS_HOST=redis
      - SPRING_REDIS_PASSWORD=xxxxxxxx
      - spring_redis_jedis_pool_maxIdle=300 # redis配置
      - spring_redis_jedis_pool_maxWait=30000
      - spring_redis_jedis_pool_maxActive=200
    restart: on-failure

原文地址:https://blog.csdn.net/u010882234/article/details/132479363

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_33338.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注