whhxdd
whhxdd
采纳率0%
2015-12-14 08:16

我的maven项目连接mongodb出现链接异常

以前还好用,也插入过数据,但是今天就不行了。
项目是maven项目,连接的mongodb在远程服务器上,而且远程服务器的ip和我的ip不在一个网段内,
我改了ip和远程服务器在一个网段后,能ping通远程服务器,但是不能上网了。就出现了mongodb连接超时
具体异常如下
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.1.0.jar:?]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.1.0.jar:?]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) [mongodb-driver-core-3.1.0.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:1.8.0_40]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[?:1.8.0_40]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[?:1.8.0_40]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_40]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_40]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[?:1.8.0_40]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_40]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_40]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~[mongodb-driver-core-3.1.0.jar:?]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.1.0.jar:?]
... 3 more

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • oyljerry oyljerry 6年前

    连接拒绝了 对应的mongodb的端口是否在侦听

    点赞 评论 复制链接分享
  • qq_30762453 DFDHZ 6年前

    看看是不是网关限制了

    点赞 评论 复制链接分享
  • qq_43277782 qq_43277782 2年前

    Exception opening socket 错误你是怎么解决的

    点赞 评论 复制链接分享

相关推荐