SpringBoot - MongoClient socket timeout

2,435 views
Skip to first unread message

Rohan Patel

unread,
Oct 12, 2019, 4:27:43 AM10/12/19
to mongodb-user
Hi,

We are seeing exceptions from our mongo db replica set. The databases have been up 100% and have not seen outages, but we see the following errors on client side.

zplv9353 is primary db.

2019-10-11 08:55:48.588  INFO 1 ---  org.mongodb.driver.connection            : Closed connection [connectionId{localValue:417, serverValue:30067}] to abc.abc.com:18720 because there was a socket exception raised on another connection from this pool.


2019-10-11 08:58:03.746  INFO 1 ---  org.mongodb.driver.cluster               : No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=[ServerDescription{address=zlpv9352.abc.com:18720, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, ServerDescription{address=zlpv9353.abc.com:18720, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, ServerDescription{address=zlpv9420.abc.com:18720, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 3]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=12122243, setName='otf-rs-prod2', canonicalAddress=zlpv9420.abc.com:18720, hosts=[zlpv9352.abc.com:18720, zlpv9353.abc.com:18720, zlpv9420.abc.com:18720], passives=[], arbiters=[], primary='zlpv9353.abc.com:18720', tagSet=TagSet{[]}, electionId=null, setVersion=5, lastWriteDate=Fri Oct 11 08:57:53 GMT 2019, lastUpdateTimeNanos=18934947630635371}]}. Waiting for 30000 ms before timing out


This causes exceptions on any read/writes to primary.

Any ideas on how to resolve this. We are using springboot & mongoclient

Virinchi samineni

unread,
Oct 12, 2019, 3:35:24 PM10/12/19
to mongodb-user
Hello
Where is your mongodb hosted?
Check whether you have allowed connections from your Ip address

Mohammad Khorrami

unread,
Oct 13, 2019, 12:45:32 AM10/13/19
to mongod...@googlegroups.com
Hi
All host on data center and we don't use mongo cloud for some restriction.
And When we use single ip without replicaSet option 
Connect to mongo work perfect 



--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8a7148dd-75c8-41ce-a040-ec66c823eac2%40googlegroups.com.

Virinchi samineni

unread,
Oct 13, 2019, 1:14:53 AM10/13/19
to mongodb-user
If you are able to connect with out replica set option
It means your replica sets may be configured wrong

Mohammad Khorrami

unread,
Oct 13, 2019, 2:42:07 AM10/13/19
to mongod...@googlegroups.com
Tnx
But when we use connection string on server 
Directly connect and not any problem


On Sun, 13 Oct 2019, 08:44 Virinchi samineni, <virinchi...@techolution.com> wrote:
If you are able to connect with out replica set option
It means your replica sets may be configured wrong

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.

Rohan Patel

unread,
Oct 14, 2019, 12:18:02 AM10/14/19
to mongodb-user
Hi. Our mongo db is hosted on several different vms. We connect as a replicaset and have seen connectivity for months. 
But we started seeing this issue this past week. I think it may have to do with the number of current connections to the database and the max allowed (haven't verified as the issue resolved after a an hour). 
My other thinking is that the connection pool on the client is being bottle necked and requests waiting to be filled time out after 30 seconds because they aren't given a connection from the pool.

Do you think these could be possible root causes?
Reply all
Reply to author
Forward
0 new messages