On the exception of MongoDB read connection timeout

Source: Internet
Author: User
Tags findone mongodb query stack trace apache tomcat

Today at the scene of the Buddies sent an exception, let me solve, the error message is as follows:

HTTP Status 500-read operation to server 192.168.1.110:20001 failed on database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP DB--------------------------------------------------------------------------------type Exception reportmessage Read operation to server 192.168.1.110:20001 failed on database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP Dbdescription the server encountered an internal error that prevented it from fulfilling this request.exception org.spring Framework.dao.DataAccessResourceFailureException:Read operation to server 192.168.1.110:20001 failed on database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP Dborg.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible ( Mongoexceptiontranslator.java: Org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException (Mongotemplate.java : 1913) org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal (mongotemplate.java:1743) Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557) Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497) Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60) Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317) Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (Reflectivemethodinvocation.java:183) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:150 ) Org.springframework.cache.interceptor.cacheinterceptor$1.invoke (cacheinterceptor.java:58) Org.springframework.cache.interceptor.CacheAspectSupport.execute (cacheaspectsupport.java:211) Org.springframework.cache.interceptor.CacheInterceptor.invoke (cacheinterceptor.java:66) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:172) Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204) com.sun.proxy.$ Proxy50.gettile (Unknown Source) Com.geoway.ime.server.rest.TileServer.getTileKVP (tileserver.java:60) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Com.sun.jersey.spi.container.JavaMethodInvokErfactory$1.invoke (JAVAMETHODINVOKERFACTORY.JAVA:60) Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185) Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( resourcejavamethoddispatcher.java:75) Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept ( httpmethodrule.java:302) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (Resourceclassrule.java : 108) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147) Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1442) Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:13) Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1381) Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716) Javax.servlet.http.HttpServlet.service (httpservlet.java:723) Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88) Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106) root cause Com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database Wpdbcom.mongodb.DBTCPConnector.innerCall (dbtcpconnector.java:308) Com.mongodb.DBTCPConnector.call ( dbtcpconnector.java:279) Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:84) Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:66) Com.mongodb.DBCollection.findOne (DBcollection.java:870) Com.mongodb.DBCollection.findOne (dbcollection.java:844) Com.mongodb.DBCollection.findOne ( dbcollection.java:790) Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection ( mongotemplate.java:1980) Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection ( mongotemplate.java:1965) org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal ( mongotemplate.java:1739) Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557) Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497) Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60) Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflecT.method.invoke (method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection ( aoputils.java:317) Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint ( reflectivemethodinvocation.java:183) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed ( reflectivemethodinvocation.java:150) Org.springframework.cache.interceptor.cacheinterceptor$1.invoke ( cacheinterceptor.java:58) Org.springframework.cache.interceptor.CacheAspectSupport.execute ( cacheaspectsupport.java:211) Org.springframework.cache.interceptor.CacheInterceptor.invoke ( cacheinterceptor.java:66) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed ( reflectivemethodinvocation.java:172) Org.springframework.aop.framework.JdkDynamicAopProxy.invoke ( jdkdynamicaopproxy.java:204) com.sun.proxy. $Proxy 50.getTile (Unknown Source) Com.geoway.ime.server.rest.TileServer.getTileKVP (TILESERVER.JAVA:60) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodACcessorimpl.invoke (nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke (JAVAMETHODINVOKERFACTORY.JAVA:60) Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185) Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( resourcejavamethoddispatcher.java:75) Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept ( httpmethodrule.java:302) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (Resourceclassrule.java : 108) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147) Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest ( webapplicationimpl.java:1442) Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest ( webapplicationimpl.java:1391) Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest ( webapplicationimpl.java:1381) Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716) Javax.servlet.http.HttpServlet.service (httpservlet.java:723) Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88) Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106) root cause Java.net.SocketTimeoutException:Read timed outjava.net.SocketInputStream.socketRead0 (Native Method) Java.net.SocketInputStream.read (socketinputstream.java:129) Java.io.BufferedInputStream.fill (bufferedinputstream.java:218) Java.io.BufferedInputStream.read1 ( bufferedinputstream.java:258) Java.io.BufferedInputStream.read (bufferedinputstream.java:317) Org.bson.io.Bits.readFully (bits.java:48) org.bson.io.Bits.readFully (bits.java:35) org.bson.io.Bits.readFully ( bits.java:30) com.mongodb.response.<init> (response.java:42) Com.mongodb.dbport$1.execute (DBPort.java:141) Com.mongodb.dbport$1.execute (dbport.java:135) com.mongodb.DBPort.doOperation (dbport.java:164) Com.mongodb.DBPort.call (dbport.java:135) Com.mongodb.DBTCPConnector.innerCall (dbtcpconnector.java:300) Com.mongodb.DBTCPConnector.call (dbtcpconnector.java:279) Com.mongodb.DBCollectionImpl.find ( dbcollectionimpl.java:84) Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:66) Com.mongodb.DBCollection.findOne (dbcollection.java:870) Com.mongodb.DBCollection.findOne (dbcollection.java:844) Com.mongodb.DBCollection.findOne (dbcollection.java:790) org.springframework.data.mongodb.core.MongoTemplate$FindOneCallback. Doincollection (mongotemplate.java:1980) org.springframework.data.mongodb.core.mongotemplate$ Findonecallback.doincollection (mongotemplate.java:1965) Org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal (mongotemplate.java:1739) Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557) Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497) Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60) Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317) Org.springframework.aop.framework.ReflectiveMethodInvocatioN.invokejoinpoint (reflectivemethodinvocation.java:183) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:150) Org.springframework.cache.interceptor.cacheinterceptor$1.invoke (cacheinterceptor.java:58) Org.springframework.cache.interceptor.CacheAspectSupport.execute (cacheaspectsupport.java:211) Org.springframework.cache.interceptor.CacheInterceptor.invoke (cacheinterceptor.java:66) Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:172) Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204) com.sun.proxy.$ Proxy50.gettile (Unknown Source) Com.geoway.ime.server.rest.TileServer.getTileKVP (tileserver.java:60) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (Method.java:597) Com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke (javamethodinvokerfactory.java:60) Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185) Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( resourcejavamethoddispatcher.java:75) Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept ( httpmethodrule.java:302) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (Resourceclassrule.java : 108) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147) Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511) Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1442) Com.sun.jersey.server.impl.application.WebApplicatIonimpl.handlerequest (webapplicationimpl.java:1391) Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1381) Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538) Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716) Javax.servlet.http.HttpServlet.service (httpservlet.java:723) Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88) Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106) Note the full stack Trace of the root cause is available in the Apache tomcat/6.0.41 logs.

By exception, this is due to a MongoDB connection timeout. So, look for the reason on MongoDB. First, on the MongoDB configuration file:

mongodb.replica-set=192.98.12.242:30007,192.98.12.245:30007mongodb.hostname=192.98.12.245mongodb.port= 30007mongodb.connections-per-host=1000mongodb.threads-allowed-to-block-for-connection-multiplier= 200mongodb.connect-timeout=mongodb.max-wait-time=-mongodb.auto-connect-retry= Truemongodb.socket-keep-alive=truemongodb.socket-timeout=1500mongodb.slave-ok=truemongodb.write-number= 1mongodb.write-timeout=1000mongodb.write-fsync=truemongodb.dbname=shardvectordbmongodb.dbuser= mongodb.dbpassword=

Connection time 2 seconds. Then in the Locate MongoDB query, the result is 6, 7 seconds. It turns out that's the reason. Then locate, why does a query take so long?

After troubleshooting, it turns out that the query field did not create an index. Then create the index, query dozens of milliseconds, OK problem all resolved.

On the exception of MongoDB read connection timeout

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.