CenterOS7安装Redis,测试 Jedis 连接超时(connect timed out)
来源:互联网 发布:java开发百度云播放器 编辑:程序博客网 时间:2024/06/05 09:24
问题描述:Redis是安装在虚拟机的CenterOS7系统上,在Windows写的Jedis程序却一直报错连接超时,使用JedisPoolConfig添加连接时间,可是一直都没有效果
- 错误信息
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out at redis.clients.jedis.Connection.connect(Connection.java:155) at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:83) at redis.clients.jedis.Connection.sendCommand(Connection.java:94) at redis.clients.jedis.BinaryClient.set(BinaryClient.java:100) at redis.clients.jedis.Client.set(Client.java:29) at redis.clients.jedis.Jedis.set(Jedis.java:65) at com.taotao.rest.jedis.JedisTest.testJedisSingle(JedisTest.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)Caused by: java.net.SocketTimeoutException: connect timed out at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at redis.clients.jedis.Connection.connect(Connection.java:149) ... 29 more
解决方法:
一、关闭CenterOS7的防火墙
[root@localhost ~]# systemctl stop firewalld.service
如果使用iptables,使用如下关闭:
[root@localhost ~]# systemctl stop iptables.service
二、如果使用Iptables 修改Iptables列表
[root@localhost ~]# vim /etc/sysconfig/iptables
修改如下:(根据你所需,开放端口)
# sample configuration for iptables service# you can edit this manually or use system-config-firewall# please do not ask us to add additional ports/services to this default configuration*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 7001:7006 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT
阅读全文
1 0
- CenterOS7安装Redis,测试 Jedis 连接超时(connect timed out)
- Jedis连接linux下redis服务器连接超时connect timed out解决
- Jedis测试异常:connect timed out
- Jedis远程链接报错(connect timed out)
- Java连接Redis碰到的坑connect timed out
- Java Jedis远程连接redis异常解决思路,异常描述:Could not get a resource from the pool && connect timed out
- Jedis远程连接Redis服务器报错(connect time out)解决方案
- Jedis远程连接Redis服务器报错(connect time out)
- fail to connect; session timed out or 连接失败 会话已超时
- 初学redis问题--connect timed out
- jedis 连接redis超时异常
- jedis连接redis服务器超时
- tomcat连接超时(connection time out : connect)
- Connection timed out: connect
- Connection timed out: connect
- Connection timed out: connect
- Redis安装&&Jedis连接Redis
- Caused by: java.net.SocketTimeoutException: connect timed out redis
- WebApi
- 《C语言入门经典》习题7.1(仅供与某人讨论使用)
- 消息队列应用场景
- SQLiteDatabase中query、insert、update、delete方法参数说明
- Java 将HTML文件转换成PDF(Windows和linux)
- CenterOS7安装Redis,测试 Jedis 连接超时(connect timed out)
- Shape Number HDU
- 9-4(线段树最大值定位,区间合并)
- 怎样用mysql查询语句得到下方表格
- 哈夫曼树
- 输出一个矩形(长方形)
- 字节流的操作(3+1)
- JDK提供复制文件三种方式
- 技术人生(20) ——ORA-01555错误启示录