org.mongodb.driver.cluster : No server chosen by ReadPreferenceServerSelecto

展开阅读全文

ubuntu 防火墙导致java程序访问mongodb报错

08-16

Hello World! 八月 16, 2016 10:02:35 下午 com.mongodb.diagnostics.logging.JULLogger log 信息: Cluster created with settings {hosts=[192.168.239.137:27107], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=50} DB{name='test'} 八月 16, 2016 10:02:35 下午 com.mongodb.diagnostics.logging.JULLogger log 信息: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=192.168.239.137:27107, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out 八月 16, 2016 10:02:36 下午 com.mongodb.diagnostics.logging.JULLogger log 信息: Exception in monitor thread while connecting to server 192.168.239.137:27107 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(Unknown Source) Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ... 3 more Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.239.137:27107, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}] at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370) at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:166) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:736) at com.mongodb.Mongo$2.execute(Mongo.java:723) at com.mongodb.DBCursor.initializeCursor(DBCursor.java:815) at com.mongodb.DBCursor.hasNext(DBCursor.java:149) at com.mgss.App.main(App.java:20) 问答

java项目连接mongoDB报错

08-14

在本地搭了环境,启动mongoDB数据库服务并进行了连接验证,如下: ![图片说明](https://img-ask.csdn.net/upload/201708/14/1502695838_396993.png) ![图片说明](https://img-ask.csdn.net/upload/201708/14/1502695905_168178.png) 启动eclipse,登录页面时会访问mongoDB,但总是连接超时,报错信息如下: org.springframework.dao.DataAccessResourceFailureException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}] at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:73) at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2002) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1885) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1696) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1679) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:598) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:589) at com.jftt.wifi.service.impl.ManageUserServiceImpl.findUserByCondition(ManageUserServiceImpl.java:301) at com.jftt.wifi.service.impl.ManageUserServiceImpl.findUserByCondition(ManageUserServiceImpl.java:273) at com.jftt.wifi.service.impl.ManageUserServiceImpl.findUserByUserName(ManageUserServiceImpl.java:664) at com.jftt.wifi.action.LoginAction.login(LoginAction.java:369) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}] at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370) at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:166) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:738) at com.mongodb.Mongo$2.execute(Mongo.java:725) at com.mongodb.DBCursor.initializeCursor(DBCursor.java:815) at com.mongodb.DBCursor.hasNext(DBCursor.java:149) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1871) ... 49 more 请问各位大侠,有碰到这样的问题么?如何解决呢? 问答

mongodb3.0.1如何关闭debug

08-11

今天在做mongodb3.0.1与java项目整合时候,发现后台总是在打印debug信息 2015-08-11 17:32:24.621 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:24.624 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.9 ms, state=CONNECTED}] 2015-08-11 17:32:25.363 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:25.365 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.6 ms, state=CONNECTED}] 2015-08-11 17:32:34.626 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:34.628 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=1.0 ms, state=CONNECTED}] 2015-08-11 17:32:35.367 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:35.369 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.7 ms, state=CONNECTED}] 2015-08-11 17:32:44.629 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:44.631 [cluster-ClusterId{value='55c9c11e80df810c54492c6b', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=1.1 ms, state=CONNECTED}] 2015-08-11 17:32:45.370 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Checking status of localhost:27017 2015-08-11 17:32:45.372 [cluster-ClusterId{value='55c9c11f80df810c54492c6c', description='null'}-localhost:27017] DEBUG o.mongodb.driver.cluster.debug(56) - Updating cluster description to {type=STAN DALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.8 ms, state=CONNECTED}] ``` ``` 请问如何关闭mongodb的这个debug信息打印 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览