Cannot connect to MongoDB Atlas replica set via SSH tunnel

Vincent Chen shared this problem 6 years ago
Solved

I have an issue to connect with MongoDB Atlas replica set via SSH tunnel.

My mongobooster version is v3.5.6 free edition and MongoDB is v3.4.4

You may apply a free account in MongoDB Atlas to reproduce.

Here is the error message:

{
	"message" : "no primary found in replicaset",
	"stack" : "MongoError: no primary found in replicaset" +
              "at C:\\Users\\my_user\\AppData\\Local\\mongobooster\\app-3.5.6\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\topologies\\replset.js:555:28" +
              "at Server.<anonymous> (C:\\Users\\my_user\\AppData\\Local\\mongobooster\\app-3.5.6\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\topologies\\replset.js:312:24)" +
              "at Object.onceWrapper (events.js:290:19)" +
              "at emitOne (events.js:96:13)" +
              "at Server.emit (events.js:188:7)" +
              "at C:\\Users\\my_user\\AppData\\Local\\mongobooster\\app-3.5.6\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\topologies\\server.js:299:14" +
              "at C:\\Users\\my_user\\AppData\\Local\\mongobooster\\app-3.5.6\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\connection\\pool.js:469:18" +
              "at _combinedTickCallback (internal/process/next_tick.js:67:7)" +
              "at process._tickCallback (internal/process/next_tick.js:98:9)",
	"name" : "MongoError"
}

Replies (3)

photo
1

It works well in my test with a free account .Please see the attached picture.

331fe5297bb1f910ad4162d00cb59f7e


Could you please give an accessible(mongo shell) test MongoDB URI to recall the issue?

photo
1

Resolved in 3.5.7

photo
1

Hello!

I had the same problem (Cannot connect to MongoDB replica set via SSH tunnel) and it reproduces in 3.5.7.

case 1 (seems like dns problem, names do not resolve behind ssh):

```

{

"message" : "failed to connect to server [mongo3:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo3 mongo3:27017]",

"stack" : "MongoError: failed to connect to server [mongo3:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo3 mongo3:27017]" +

"at Pool. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\topologies\\server.js:328:35)" +

"at emitOne (events.js:96:13)" +

"at Pool.emit (events.js:188:7)" +

"at Connection. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\connection\\pool.js:280:12)" +

"at Object.onceWrapper (events.js:290:19)" +

"at emitTwo (events.js:106:13)" +

"at Connection.emit (events.js:191:7)" +

"at Socket. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\connection\\connection.js:177:49)" +

"at Object.onceWrapper (events.js:290:19)" +

"at emitOne (events.js:96:13)" +

"at Socket.emit (events.js:188:7)" +

"at connectErrorNT (net.js:1025:8)" +

"at _combinedTickCallback (internal/process/next_tick.js:74:11)" +

"at process._tickCallback (internal/process/next_tick.js:98:9)",

"name" : "MongoError"

}

```


ok, place mongo1,mongo2,mongo3 to hosts with IPs behind ssh:

```

{

"message" : "failed to connect to server [mongo3:27017] on first connect [MongoError: connect ETIMEDOUT 10.0.1.4:27017]",

"stack" : "MongoError: failed to connect to server [mongo3:27017] on first connect [MongoError: connect ETIMEDOUT 10.0.1.4:27017]" +

"at Pool. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\topologies\\server.js:328:35)" +

"at emitOne (events.js:96:13)" +

"at Pool.emit (events.js:188:7)" +

"at Connection. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\connection\\pool.js:280:12)" +

"at Object.onceWrapper (events.js:290:19)" +

"at emitTwo (events.js:106:13)" +

"at Connection.emit (events.js:191:7)" +

"at Socket. (C:\\Users\\Dalamar81\\AppData\\Local\\mongobooster\\app-3.5.7\\resources\\app.asar\\node_modules\\mongodb-core\\lib\\connection\\connection.js:177:49)" +

"at Object.onceWrapper (events.js:290:19)" +

"at emitOne (events.js:96:13)" +

"at Socket.emit (events.js:188:7)" +

"at emitErrorNT (net.js:1281:8)" +

"at _combinedTickCallback (internal/process/next_tick.js:74:11)" +

"at process._tickCallback (internal/process/next_tick.js:98:9)",

"name" : "MongoError"

}

```

photo
1

Thank you for your feedback.

Can you connect your atlas service with mongoDB shell and SSH tunnel?


To locate the issue, I need to recall the issue locally? If possible, could you give me an accessible(mongo shell) test MongoDB URI and temporary SSH account to recall the issue?

photo
1

I have the same error to tunnel in the cluster mongo server.

photo
1

the same error mongobooster 4.1.2, mongodb 3.4.4 with replica

"message" : "failed to connect to server [10.0.1.206:27017] on first connect [MongoError: connection 5 to 10.0.1.206:27017 timed out]",

"stack" : "MongoError: failed to connect to server [10.0.1.206:27017] on first connect [MongoError: connection 5 to 10.0.1.206:27017 timed out]" +

"at Pool.<anonymous> (/Applications/mongobooster.app/Contents/Resources/app.asar/node_modules/qh-mongodb/node_modules/mongodb-core/lib/topologies/server.js:336:35)" +

"at emitOne (events.js:96:13)" +

"at Pool.emit (events.js:191:7)" +

"at Connection.<anonymous> (/Applications/mongobooster.app/Contents/Resources/app.asar/node_modules/qh-mongodb/node_modules/mongodb-core/lib/connection/pool.js:280:12)" +

"at Object.onceWrapper (events.js:293:19)" +

"at emitTwo (events.js:106:13)" +

"at Connection.emit (events.js:194:7)" +

"at Socket.<anonymous> (/Applications/mongobooster.app/Contents/Resources/app.asar/node_modules/qh-mongodb/node_modules/mongodb-core/lib/connection/connection.js:197:10)" +

"at Object.onceWrapper (events.js:293:19)" +

"at emitNone (events.js:86:13)" +

"at Socket.emit (events.js:188:7)" +

"at Socket._onTimeout (net.js:351:8)" +

"at ontimeout (timers.js:386:14)" +

"at tryOnTimeout (timers.js:250:5)" +

"at Timer.listOnTimeout (timers.js:214:5)",

"name" : "MongoError"

}

photo
Leave a Comment
 
Attach a file