MongoDB Connection Timeout
See original GitHub issueHello,
My setup: Dbeaver 4.1.1 EE (Windows 10) / MongoDB 3.2.12 on Ubuntu 16.04 under local Hyper-V Virtual Machine.
Lets start with what i get from dbeaver: 1)
Error connecting to Mongo instance [127.0.0.1]
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that
matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is
{type=REPLICA_SET, servers=[{address=wslu.sys:27017, type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketException: wslu.sys}, caused by
{java.net.UnknownHostException: wslu.sys}}]
and
Error connecting to Mongo instance [192.168.1.2]
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that
matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is
{type=REPLICA_SET, servers=[{address=wslu.sys:27017, type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketException: wslu.sys}, caused by
{java.net.UnknownHostException: wslu.sys}}]
Ad.1) Odd thing about this part is, i’m trying to connect here, to my mongodb using SSH tunnel, which is set to my local VM ip: 192.168.1.2 and mongo instance on that VM, also with IP 192.168.1.2. However in that error we can see both: 127.0.0.1 AND wslu.sys (vm hostname) - its odd. It should be 192.168.1.2 in both places, shouldn’t it?
Ad.2) This time, i’m trying to connect to my mongo instance DIRECTLY, so by using VM ip 192.168.1.2, but again, we can see here, that somehow its trying to connect to server wslu.sys.
Both, errors are popping up when i’m NOT filling Replica Set field in connection settings. But, when i do (in scenario without ssh tunnel):
Error connecting to Mongo instance [192.168.1.2]
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that
matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is
{type=REPLICA_SET, servers=[]
I really don’t get it. Any advice?
EDIT: My RS status output from mongo:
/* 1 */
{
"set" : "rs",
"date" : ISODate("2017-08-14T00:07:22.324Z"),
"myState" : 1,
"term" : NumberLong(68),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 0,
"name" : "wslu.sys:27017",
"health" : 1.0,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 366700,
"optime" : {
"ts" : Timestamp(1502667624, 2),
"t" : NumberLong(68)
},
"optimeDate" : ISODate("2017-08-13T23:40:24.000Z"),
"electionTime" : Timestamp(1502302543, 1),
"electionDate" : ISODate("2017-08-09T18:15:43.000Z"),
"configVersion" : 1,
"self" : true
}
],
"ok" : 1.0
}
Btw. RoboMongo connects without issues.
Issue Analytics
- State:
- Created 6 years ago
- Comments:24 (15 by maintainers)
Top GitHub Comments
Extra driver property was added. It may help in case of SSH tunnel and replica sets. You could try it in version 4.3:
I can’t say because I can’t reproduce this. And I don’t fully understand the nature of this problem.
Did you try to use some 3rd party SSH client (e.g. Putty) for SSH tunnel? (https://blockdev.io/connecting-to-a-mongo-replica-set-via-ssh/)