我在heroku上部署了一个部署的Springboot服务器,它的运行方式与mlab一样,除了mlab之外不会创建连接。奇怪的是,它工作了一次,但我不得不重新启动服务器,它再也没有连接过。我尝试在不启动mongodb的情况下启动服务器,在本地重新创建了该问题。我得到的错误是
2017-05-24T13:10:56.522858+00:00 app[web.1]:
2017-05-24T13:10:56.522859+00:00 app[web.1]: com.mongodb.MongoSocketOpenException: Exception opening socket
2017-05-24T13:10:56.522860+00:00 app[web.1]: at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar!/:na]
2017-05-24T13:10:56.522861+00:00 app[web.1]: at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar!/:na]
2017-05-24T13:10:56.522862+00:00 app[web.1]: at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar!/:na]
2017-05-24T13:10:56.522863+00:00 app[web.1]: at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522863+00:00 app[web.1]: Caused by: java.net.ConnectException: Connection refused (Connection refused)
2017-05-24T13:10:56.522865+00:00 app[web.1]: at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522865+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522866+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522867+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522867+00:00 app[web.1]: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522868+00:00 app[web.1]: at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_121-heroku16]
2017-05-24T13:10:56.522869+00:00 app[web.1]: at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar!/:na]
2017-05-24T13:10:56.522869+00:00 app[web.1]: at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar!/:na]
2017-05-24T13:10:56.522871+00:00 app[web.1]: ... 3 common frames omitted
我使用spring.data.mongodb.uri = $ {MONGODB_URI}来拉动mongo uri,但我根本没有运气。我一直试图让这个连接两天,而不是只有一个成功的连接,出于一些奇怪的原因。任何建议将不胜感激。