为了解决这个问题:我是否需要在Heroku上获得SSL支持才能使用SSL在Heroku和Atlas MongoDB Cloud之间建立连接?(TSL/SSL连接是访问Atlas MongoDB云服务的首选连接).
我正在try 连接我的Heroku应用程序,用node编写.js,到Atlas MongoDB Cloud托管的集群.
我当前的数据库托管在mLab(作为Heroku插件),用于通过mongoose访问集群的MongoDB URI是(使用xxx省略机密信息):
MONGODB_URI="mongodb://xxx:xxx@xxx-a0.mlab.com:23266,xxx-a1.mlab.com:xxx/xxx?replicaSet=rs-xxx"
现在我已经将数据从mLab迁移到Atlas MongoDB Cloud,现在我正在使用URI访问集群:
MONGODB_URI="mongodb://xxx:xxx@cluster0-shard-xxx.mongodb.net:xxx,cluster0-shard-xxx.mongodb.net:xxx,cluster0-shard-xxx.mongodb.net:xxx/xxx?replicaSet=xxx&ssl=true&authSource=admin"
在我的机器上本地运行Heroku应用程序时,我可以毫无问题地访问数据库.我还可以使用mongo shell连接到集群.
但是,在Heroku中运行应用程序时,无法建立连接.在浏览器JS控制台中,我收到503服务不可用消息.在heroku中,我得到了一个错误:
no primary found in replica set
我知道Atlas MongoDB云需要SSL连接,这与mLab不同.在我的本地机器中,我假设正在使用自签名证书成功连接到集群.
我的问题是:为了能够在Heroku和MongoDB Atlas之间建立安全连接,我是否需要在Heroku中获得SSL支持?或者Heroku中的SSL支持仅用于客户端/Heroku安全连接?