admin管理员组文章数量:1418972
Getting this mongodb related error in spring-boot 2.0.6.RELEASE. This is happening frequently and when making API call, API's where going into pending state. Sometime it is working fine. Want to know why it is happening? How to resolve this?
2025-01-29 09:43:19.509 WARN 110974 --- [io-8081-exec-13] .mongodb.driver.connection : Got socket exception on connection [connectionId{localValue:45, serverValue:1893}] to 4.213.70.7:27017. All connections to 4.213.70.7:27017 will be closed.
2025-01-29 09:43:19.510 INFO 110974 --- [io-8081-exec-13] .mongodb.driver.connection : Closed connection [connectionId{localValue:45, serverValue:1893}] to 4.213.70.7:27017 because there was a socket exception raised by this connection.
.springframework.data.mongodb.UncategorizedMongoDbException: Exception receiving message; nested exception is com.mongodb.MongoSocketReadException: Exception receiving message
at .springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:132)
at .springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2607)
at .springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:527)
at .springframework.data.mongodb.core.MongoTemplate.count(MongoTemplate.java:962)
at .springframework.data.mongodb.core.MongoTemplate.count(MongoTemplate.java:942)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl.findByCriteria(WhatsAppTemplateCustomRepositoryImpl.java:58)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl$$FastClassBySpringCGLIB$$327a5469.invoke(<generated>)
at .springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at .springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at .springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl$$EnhancerBySpringCGLIB$$c4a866df.findByCriteria(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at .springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377)
at .springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
at .springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:641)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at .springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:590)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy156.findByCriteria(Unknown Source)
at sun.reflect.GeneratedMethodAccessor456.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Getting this mongodb related error in spring-boot 2.0.6.RELEASE. This is happening frequently and when making API call, API's where going into pending state. Sometime it is working fine. Want to know why it is happening? How to resolve this?
2025-01-29 09:43:19.509 WARN 110974 --- [io-8081-exec-13] .mongodb.driver.connection : Got socket exception on connection [connectionId{localValue:45, serverValue:1893}] to 4.213.70.7:27017. All connections to 4.213.70.7:27017 will be closed.
2025-01-29 09:43:19.510 INFO 110974 --- [io-8081-exec-13] .mongodb.driver.connection : Closed connection [connectionId{localValue:45, serverValue:1893}] to 4.213.70.7:27017 because there was a socket exception raised by this connection.
.springframework.data.mongodb.UncategorizedMongoDbException: Exception receiving message; nested exception is com.mongodb.MongoSocketReadException: Exception receiving message
at .springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:132)
at .springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2607)
at .springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:527)
at .springframework.data.mongodb.core.MongoTemplate.count(MongoTemplate.java:962)
at .springframework.data.mongodb.core.MongoTemplate.count(MongoTemplate.java:942)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl.findByCriteria(WhatsAppTemplateCustomRepositoryImpl.java:58)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl$$FastClassBySpringCGLIB$$327a5469.invoke(<generated>)
at .springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at .springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at .springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.cmcp.mongorepository.implementation.WhatsAppTemplateCustomRepositoryImpl$$EnhancerBySpringCGLIB$$c4a866df.findByCriteria(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at .springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377)
at .springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
at .springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:641)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at .springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:590)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at .springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy156.findByCriteria(Unknown Source)
at sun.reflect.GeneratedMethodAccessor456.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Share
Improve this question
edited Jan 29 at 13:41
Wernfried Domscheit
59.8k10 gold badges90 silver badges128 bronze badges
asked Jan 29 at 12:17
VijayVijay
11 bronze badge
1 Answer
Reset to default 0The error you're seeing (MongoSocketReadException) usually happens because of network issues or problems with the MongoDB server, like high load or slow responses.
To fix it:
Check MongoDB health: make sure the server is up and stable, and that there are no network issues.
Increase timeouts: in your application.properties, try adjusting the connection and socket timeouts:
spring.data.mongodb.uri=mongodb://<user>:<password>@<host>:<port>/<db>?socketTimeoutMS=60000&connectTimeoutMS=30000&maxPoolSize=50
Monitor connection usage: make sure you're not running out of available connections. Increase the connection pool size if needed.
Update MongoDB driver: if you're not using the latest version, try upgrading it.
These steps should help make your connection more stable and prevent the errors from happening.
本文标签:
版权声明:本文标题:java - Got socket exception on connection [connectionId{localValue:45, serverValue:1893}] to <server IP>. All conn 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745298533a2652228.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论