Zookeeper
When you connect to a remote redis instance using Jedis today, a connection timeout exception is thrown: connect timed out. The details are as follows:
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed outat redis.clients.jedis.Connection.connect(Connection.java:142)at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:75)at redis.clients.jedis.Connection.sendCommand(Connection.java:83)at redis.clients.jedis.BinaryClient.set(BinaryClient.java:92)at redis.clients.jedis.Client.set(Client.java:23)at redis.clients.jedis.Jedis.set(Jedis.java:53)at com.ado.test.redis.RedisTest.main(RedisTest.java:10)Caused by: java.net.SocketTimeoutException: connect timed outat java.net.PlainSocketImpl.socketConnect(Native Method)at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)at java.net.Socket.connect(Socket.java:529)at redis.clients.jedis.Connection.connect(Connection.java:137)... 6 more
Several possibilities have been ruled out after confirmation:
1. The server address is incorrectly configured. (The configuration is correct after confirmation .)
2. There are too many redis connections. (It has been confirmed that there is no connection to the redis server .)
Check the Jedis Connection source code, and no exception is found, so it is suspected that it is a problem with the redis host. Use the Telnet command to test the connection. It is suspected that the redis server firewall is not closed.
View the Server Firewall Status:
services iptables status
Disable Firewall:
services iptables stop
Then connect, and the connection will soon be successful. Solve the problem.
Redis remote connection timeout