最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

mongodb - Rancher can't communicate with DocumentDB - Stack Overflow

programmeradmin3浏览0评论

I have a MongoDB in Documentdb. If I access to it using a tunnel like this:

ssh -o StrictHostKeyChecking=no -i "/opt/app/src/mongo-key-pair.pem" -L 27017:documentdbcluster:27017 ec2-user@ec2dns -f -N

and a connection string like this:

mongodb://user:password@localhost:27017/dbname?ssl=true&tlsAllowInvalidHostnames=true&tlsAllowInvalidCertificates=true&authSource=admin&replicaSet=rs0&directConnection=true&retryWrites=false

everything works.

However I'm now trying to access from a Rancher that is in the same VPC that the documentDB, with the following connection string and pymongo and it doesn't work. The connection string is a copy of the one that documentdb gives as example. I run this from within the pod. I'm following the instructions documentdb tells

wget .pem

And then I open a Python console

import pymongo
connection_string = 'mongodb://user:<insertYourPassword>@documentdbcluster:27017/dbname?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false&authSource=admin'
client = pymongo.MongoClient(connection_string)
db = client["dbname"]
column = db["column"]
column.find_one()

I get this error:

pymongo.errors.ServerSelectionTimeoutError: cluster:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 67d86679bbd53a3fe9d26502, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('cluster', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('cluster:27017: timed out')>]>

I've tried to add also the directConnection parameter as I did on the example of the tunnel but it didn't work either?

What's wrong? Is this a network error or something else

I have a MongoDB in Documentdb. If I access to it using a tunnel like this:

ssh -o StrictHostKeyChecking=no -i "/opt/app/src/mongo-key-pair.pem" -L 27017:documentdbcluster:27017 ec2-user@ec2dns -f -N

and a connection string like this:

mongodb://user:password@localhost:27017/dbname?ssl=true&tlsAllowInvalidHostnames=true&tlsAllowInvalidCertificates=true&authSource=admin&replicaSet=rs0&directConnection=true&retryWrites=false

everything works.

However I'm now trying to access from a Rancher that is in the same VPC that the documentDB, with the following connection string and pymongo and it doesn't work. The connection string is a copy of the one that documentdb gives as example. I run this from within the pod. I'm following the instructions documentdb tells

wget https://truststore.pki.rds.amazonaws/global/global-bundle.pem

And then I open a Python console

import pymongo
connection_string = 'mongodb://user:<insertYourPassword>@documentdbcluster:27017/dbname?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false&authSource=admin'
client = pymongo.MongoClient(connection_string)
db = client["dbname"]
column = db["column"]
column.find_one()

I get this error:

pymongo.errors.ServerSelectionTimeoutError: cluster:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 67d86679bbd53a3fe9d26502, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('cluster', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('cluster:27017: timed out')>]>

I've tried to add also the directConnection parameter as I did on the example of the tunnel but it didn't work either?

What's wrong? Is this a network error or something else

Share Improve this question asked Mar 17 at 18:24 CarabesCarabes 6992 gold badges7 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The problem was related with the permissions of the security group that was involved. Once that was fixed I could make this work, even without the trick of the tunnel

发布评论

评论列表(0)

  1. 暂无评论