MongoDB is composed of mongos, replica-set, and consists of four shards. (version 4.2.19)
Data is being loaded in real time on MongoDB.
In this situation, I would like to know the settings that recommend connectTimeoutMS, socketTimeoutMS, maxTimeMS, and KeepAlive.
I am changing the setting value and monitoring it, but the error below occurs frequently.
Exception sending message; nested exception is com.mongodb.MongoSocketWriteException: Exception sending message
I use spring-data-mongo 3.0.9 version and mongo driver 4.6 version.
There are two intermittent errors when saving data to mongodb in the spring boot application.
case 1 :
Exception sending message; nested exception is com.mongodb.MongoSocketWriteException
case 2 :
Prematurely reached end of stream; nested exception is com.mongodb.MongoSocketReadException
The application uses the save method in mongoTemplate when saving data.
The mongodb setting in the application.yml of the spring boot application is shown below.
Hi @rinjyu_N_A and thank you for sharing the above details
The above issue might have occurred due to message being transmitted over a closed socket.
Can you also confirm if there is pattern observed for the above problem. For example, if the app was running for a while?
The following post on stackoverflow might have a possible solution.