Ticket : Connection Pooling

Hi All,

Our requirement is maximum size of the connection pool to 50 connections so i added the following to the URL in applications.properties file

mongodb+srv://student:password@cluster.mongodb.net/test?maxPoolSize=50

But when i am running the spring boot application I am getting error as

“com.mongodb.MongoSocketReadException: Prematurely reached end of stream”

2021-03-23 15:28:01.192  INFO 29176 --- [ngodb.net:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mflix-shard-00-00.82bwb.mongodb.net:27017

com.mongodb.MongoSocketReadException: Prematurely reached end of stream
        at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:112) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:570) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:441) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:106) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.9.1.jar:na]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2021-03-23 15:28:01.192  INFO 29176 --- [ngodb.net:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mflix-shard-00-02.82bwb.mongodb.net:27017

com.mongodb.MongoSocketReadException: Prematurely reached end of stream
        at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:112) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:570) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:441) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:106) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.9.1.jar:na]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2021-03-23 15:28:01.330  INFO 29176 --- [ngodb.net:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mflix-shard-00-01.82bwb.mongodb.net:27017

com.mongodb.MongoSocketReadException: Prematurely reached end of stream
        at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:112) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:570) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:441) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:106) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.9.1.jar:na]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2021-03-23 15:28:34.600  INFO 29176 --- [ngodb.net:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mflix-shard-00-00.82bwb.mongodb.net:27017

com.mongodb.MongoSocketReadException: Exception receiving message
        at com.mongodb.internal.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:559) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:444) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.sendAndReceive(CommandHelper.java:83) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.CommandHelper.executeCommand(CommandHelper.java:33) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:106) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:63) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.9.1.jar:na]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
Caused by: javax.net.ssl.SSLException: Connection reset
        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[na:na]
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:369) ~[na:na]
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:312) ~[na:na]
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:307) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1680) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1054) ~[na:na]
        at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:109) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:570) ~[mongodb-driver-core-3.9.1.jar:na]
        at com.mongodb.internal.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:441) ~[mongodb-driver-core-3.9.1.jar:na]
        ... 9 common frames omitted
        Suppressed: java.net.SocketException: Connection reset by peer
                at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420) ~[na:na]
                at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440) ~[na:na]
                at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826) ~[na:na]
                at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1051) ~[na:na]
                at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:82) ~[na:na]
                at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:400) ~[na:na]
                ... 16 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:323) ~[na:na]
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350) ~[na:na]
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803) ~[na:na]
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:981) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1434) ~[na:na]
        at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1038) ~[na:na]
        ... 12 common frames omitted

Can anyone please help me with the same.