[solved] com.mongodb.MongoSocketReadException: Prematurely reached end of stream

The error was solved by the format of connection (using the parameters maxIdleTimeMS, SSL, and authSource):

maxIdleTimeMS – the maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed.

Solution: Modify the database connection like below:

spring.data.mongodb.uri=mongodb+srv://admin:[email protected]/orders?retryWrites=true&w=majority&maxIdleTimeMS=15000

Hope it will help

Leave a Reply