com.mongodb.MongoSocketOpenException: Exception opening socket

Hi All,

Sometimes for one hour we are having connection issue in between Spring BootApplication 2.0.0 Release version with Mongo Db Java driver 3.11.1.
Application is deployed in Azure App service.It works good but some of the requests are getting below issue.

com.mongodb.MongoSocketOpenException: Exception opening socket
	at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.1.jar!/:na]
	at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.1.jar!/:na]
	at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.1.jar!/:na]
	at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
Caused by: java.net.SocketTimeoutException: connect timed out
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[na:na]
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[na:na]
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:na]
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source) ~[na:na]
	at java.base/java.net.Socket.connect(Unknown Source) ~[na:na]
	at java.base/sun.security.ssl.SSLSocketImpl.connect(Unknown Source) ~[na:na]
	at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.11.1.jar!/:na]
	at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79) ~[mongodb-driver-core-3.11.1.jar!/:na]
	at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.1.jar!/:na].

Please let me know if anyone have similar issue.

Hi @vamsi_krishna welcome to the community!

It seems that the error was a connection time out from the java.net side and not from the MongoDB driver particularly. I’m not sure why this is so, since the reason may be specific to Azure App Service.

Do you see a similar issue when not using the App Service? Also, it could be a limitation of certain pricing tier. Have you tried using a higher tier and see a similar failure?

Best regards,
Kevin

@Kevin.
Thank you for responding to my query.
Yes, we are seeing this issue in Azure APP service. It is working good in local system.
Regarding app service plans. Sure, will check that one.

Thank you.

@kevinadi

We are using Production P2V2 App Service Plan in Azure.