'Why do we get com.mongodb.MongoSocketReadException?

It's intermittent, While reading data from API sometimes API gives 500 status. and log has

Error in custom provider, com.mongodb.MongoSocketReadException: Exception receiving message

Error in custom provider, com.mongodb.MongoSocketWriteException: Exception sending message

To resolve this I added ?maxIdleTimeMS=120000, still the same error. Below is application.yaml configuration.

mongoDb:

  clients:

    mefistoMongoClient:

      databases: :'Test_DB'

      uri: mongodb://${'localhost:27017/?maxIdleTimeMS=120000'}

Why are we getting this error and what could be a possible fix?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source