容器互联问题


jetty容器发布应用,连接mongodb容器报错no route to host,但是jetty容器与mongodb容器之间是连接的,

com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) ~
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method) ~
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~
at java.net.Socket.connect(Socket.java:589) ~
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~
... 3 common frames omitted
已邀请:

Milanello1998 - 李卓

赞同来自:


可能是MongoDB端的设置问题。可以尝试先不从jetty容器连接MongoDB,先从host机器traceroute一下MongoDB。如果可以,再怀疑两个容器的连通性问题。通常这种错误是MongoDB的bind IP设了限制或者有firewall。

要回复问题请先登录注册