Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to connect to any host resolved for DNS name. #3904

Closed
nagesh-sys opened this issue Jul 23, 2024 · 1 comment
Closed

Failed to connect to any host resolved for DNS name. #3904

nagesh-sys opened this issue Jul 23, 2024 · 1 comment

Comments

@nagesh-sys
Copy link

Failed to perform put and get operations into Redis

Here is the stack trance

redis.clients.jedis.exceptions.JedisConnectionException: Failed to connect to any host resolved for DNS name.
	at redis.clients.jedis.DefaultJedisSocketFactory.connectToFirstSuccessfulHost(DefaultJedisSocketFactory.java:63) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.DefaultJedisSocketFactory.createSocket(DefaultJedisSocketFactory.java:89) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.Connection.connect(Connection.java:194) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.Connection.initializeFromClientConfig(Connection.java:392) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.Connection.<init>(Connection.java:67) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.ConnectionFactory.makeObject(ConnectionFactory.java:59) ~[jedis-5.1.2.jar:?]
	at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:566) ~[commons-pool2-2.12.0.jar:2.12.0]
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:306) ~[commons-pool2-2.12.0.jar:2.12.0]
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:233) ~[commons-pool2-2.12.0.jar:2.12.0]
	at redis.clients.jedis.util.Pool.getResource(Pool.java:38) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.ConnectionPool.getResource(ConnectionPool.java:29) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.ConnectionPool.getResource(ConnectionPool.java:7) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.providers.PooledConnectionProvider.getConnection(PooledConnectionProvider.java:68) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.executors.DefaultCommandExecutor.executeCommand(DefaultCommandExecutor.java:23) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.UnifiedJedis.executeCommand(UnifiedJedis.java:252) ~[jedis-5.1.2.jar:?]
	at redis.clients.jedis.UnifiedJedis.get(UnifiedJedis.java:730) ~[jedis-5.1.2.jar:?]

I configured the JedisPool like below

var redisHostName = System.getenv("REDIS_HOST");
		var redisPort = null !=  System.getenv("REDIS_PORT") ? Integer.parseInt(System.getenv("REDIS_PORT")) : 6379;
		var redisUserName = System.getenv("REDIS_USERNAME");
		var redisPassword = System.getenv("REDIS_PASSWORD");

		GenericObjectPoolConfig<Jedis> poolConfig = new GenericObjectPoolConfig<>();
		poolConfig.setMaxTotal(2000); // Set maximum number of connections
		poolConfig.setMaxIdle(300);  // Set maximum number of idle connections
		poolConfig.setMinIdle(100);   // Set minimum number of idle connections
		int timeout = 60000;
			        
		 JedisPool jedispool= new JedisPool(poolConfig, redisHostName, redisPort, timeout, redisUserName, redisPassword);

Redis / Jedis Configuration

Jedis version: 5.1.2

Java version: java 11

org.apache.commons : commons-pool2 2.12.0

@sazzad16
Copy link
Collaborator

Duplicate #3877

@sazzad16 sazzad16 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants