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:
Hope it will helps