If you get java.net.SocketTimeoutException: Read timed out exception
Try setting own timeout value when constructing JedisPool using the following constructor:
JedisPool(GenericObjectPool.Config poolConfig, String host, int port, int timeout)
Default timeout value is 2 seconds.
JedisPool blocks after getting 8 connections
JedisPool defaults to 8 connections, you can change this in the PoolConfig:
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(maxTotal); // maximum active connections poolConfig.setMaxIdle(maxIdle); // maximum idle connections
Take into account that JedisPool inherits commons-pool BaseObjectPoolConfig which has a lot of configuration parameters. We've set some defined ones which suit most of the cases. In case, you experience issues tuning these parameters may help.
https://github.com/xetorthio/jedis/wiki/FAQ#jedispool-blocks-after-getting-8-connections
本文介绍了如何通过调整JedisPool配置来解决Java应用程序中出现的Socket超时异常。包括设置自定义超时值和最大连接数等参数。
289

被折叠的 条评论
为什么被折叠?



