redis遠端連線逾時

來源:互聯網
上載者:User

標籤:java   jedis   redis   



     今天在用jedis串連遠端redis時,拋出連線逾時異常:connect timed out。具體資訊如下:

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

    經過確認,排除了幾種可能:

    1、伺服器位址配置錯誤。(經確認,配置無誤。)

    2、redis串連數量過多。(經確認,沒有任何串連在redis伺服器上。)

    查看jedis串連源碼,也沒發現有什麼異常,於是懷疑是redis主機的問題。使用telnet命令進行測試,發現也是串連不上。於是懷疑是redis伺服器防火牆沒關閉。

    查看伺服器防火牆狀態:

services iptables status


    關閉防火牆:

services iptables stop


    然後再進行串連,這次就很快串連成功了。問題解決。


redis遠端連線逾時

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.