Hello,
I hope I open this issue in the correct repository. We have run into performance issues with applications taking a long time (minutes) noticing an unresponsive mongos and switching to another one (our mongos are registered in a _mongodb._tcp SRV record).
Trying to tweak socketTimeoutMS has the inconvenient of false positives on slow queries. Could there be another system in the driver that would allow proactively monitoring mongos reactivity? Thanks in advance.
{"exception":{"stacktrace":"com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message\n\tat com.mongodb.internal.connection.InternalStreamConnection.createReadTimeoutException(InternalStreamConnection.java:819)\n\tat com.mongodb.internal.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:807)\n\tat com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:857)\n\tat com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:517)\n\tat com.mongodb.internal.connection.InternalStreamConnection.receive(InternalStreamConnection.java:469)\n\tat com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitor.lookupServerDescription(DefaultServerMonitor.java:249)\n\tat com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitor.run(DefaultServerMonitor.java:176)\nCaused by: java.net.SocketTimeoutException: Read timed out\n\tat java.base\/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:278)\n\tat java.base\/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:304)\n\tat java.base\/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346)\n\tat java.base\/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796)\n\tat java.base\/java.net.Socket$SocketInputStream.read(Socket.java:1099)\n\tat com.mongodb.internal.connection.SocketStream.read(SocketStream.java:182)\n\tat com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:824)\n\t... 4 more","exception_class":"com.mongodb.MongoSocketReadTimeoutException","exception_message":"Timeout while receiving message"},"source_host":"mp-callback-01-preproduction","method":"info","level":"INFO","message":"Exception in monitor thread while connecting to server mongo-main-02-b.preproduction.*************","mdc":{},"@timestamp":"2026-07-22T12:08:47.463Z","file":"SLF4JLogger.java","line_number":"76","thread_name":"cluster-ClusterId{value='6a6065c9df80181d53fd1b48', description='**********'}-mongo-main-02-b.***************","@version":1,"logger_name":"org.mongodb.driver.cluster","class":"com.mongodb.internal.diagnostics.logging.SLF4JLogger"}
{"exception":{"stacktrace":"com.mongodb.MongoSocketOpenException: Exception opening socket\n\tat com.mongodb.internal.connection.SocketStream.lambda$open$0(SocketStream.java:85)\n\tat java.base\/java.util.Optional.orElseThrow(Optional.java:403)\n\tat com.mongodb.internal.connection.SocketStream.open(SocketStream.java:85)\n\tat com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:233)\n\tat com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitor.lookupServerDescription(DefaultServerMonitor.java:219)\n\tat com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitor.run(DefaultServerMonitor.java:176)\nCaused by: java.net.SocketTimeoutException: Connect timed out\n\tat java.base\/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)\n\tat java.base\/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592)\n\tat java.base\/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)\n\tat java.base\/java.net.Socket.connect(Socket.java:751)\n\tat com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:76)\n\tat com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:104)\n\tat com.mongodb.internal.connection.SocketStream.open(SocketStream.java:79)\n\t... 3 more","exception_class":"com.mongodb.MongoSocketOpenException","exception_message":"Exception opening socket"},"source_host":"mp-callback-01-preproduction","method":"info","level":"INFO","message":"Exception in monitor thread while connecting to server mongo-main-02-b.*********************","mdc":{},"@timestamp":"2026-07-22T12:20:17.787Z","file":"SLF4JLogger.java","line_number":"76","thread_name":"cluster-ClusterId{value='6a6065c9df80181d53fd1b48', description='***********'}-mongo-main-02-b.**************","@version":1,"logger_name":"org.mongodb.driver.cluster","class":"com.mongodb.internal.diagnostics.logging.SLF4JLogger"}
Hello,
I hope I open this issue in the correct repository. We have run into performance issues with applications taking a long time (minutes) noticing an unresponsive mongos and switching to another one (our mongos are registered in a _mongodb._tcp SRV record).
Trying to tweak socketTimeoutMS has the inconvenient of false positives on slow queries. Could there be another system in the driver that would allow proactively monitoring mongos reactivity? Thanks in advance.