使用mongoose和Fixie连接到mongodb(Heroku附加组件) [英] Connecting to mongodb using mongoose and Fixie (Heroku add-on)

查看:67
本文介绍了使用mongoose和Fixie连接到mongodb(Heroku附加组件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Atlas MongoDB Cloud集群上托管了一个mongodb数据库.我目前正在使用猫鼬访问node.js应用程序中的数据库:

I have a mongodb database hosted on an Atlas MongoDB Cloud cluster. I'm currently accessing the database in my node.js application using mongoose:

mongoose.connect("mongodb://user:pw@cluster0-shard-00-00-***.mongodb.net:***,cluster0-shard-00-01-***.mongodb.net:***,cluster0-shard-00-02-***.mongodb.net:***/admin?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin");

因为Atlas MongoDB Cloud有一个白名单,而Heroku无法为我的应用程序获取固定的IP地址,所以我使用的是

Because Atlas MongoDB Cloud have a whitelist, and Heroku doesn't provide the possibility to obtain a fixed IP address for my application, I'm using Fixie add-on. Basically Fixie acts as a proxy for outbound traffic.

这样,我可以通过HTTP请求资源,这些资源通过Fixie提供的固定IP地址进行隧道传输.但是我要做的是使用Fixie的代理连接到Atlas Cloud集群,以便从数据库中检索和修改数据.

This way, I can request resources via HTTP, which are tunneled through a fixed IP address provided by Fixie. But what I do need is to connect to the Atlas Cloud cluster using Fixie's proxy, in order to retrieve and modify data from the database.

可以用猫鼬吗?

mongoose.connect函数接受选项参数,但是我不能找到有关通过代理建立连接的任何选择.

The mongoose.connect function accepts an option parameter, but I couldn't find any option regarding the establishment of a connection through a proxy.

推荐答案

刚从Fixie团队得到答复:

Just got a reply from Fixie's team:

Fixie是一个http/https代理,因此不适用于较低级别的TCP连接,例如您需要的mongodb连接

Fixie is an http/https proxy, so it won't work for lower-level TCP connections like you'd need for your mongodb connection

当我询问在这种情况下使用SOCKS的可能性时,他们回答:

When I asked about the possibility of using SOCKS for this case, they replied:

猫鼬似乎本身并不支持袜子代理,并且不接受自定义套接字(这是MySQL和Postgres的Node数据库驱动程序如何支持它的原因).

It looks like mongoose does not natively support socks proxies, and it does not accept a custom socket (which is how Node database drivers for MySQL and Postgres support it).

显然,就我而言,无法通过Fixie(Heroku附加组件)提供的代理解决方案使用猫鼬建立与MongoDB Atlas集群的连接.

So apparently, in my case, there is no way to establish a connection to MongoDB Atlas cluster using mongoose through the proxy solution offered by Fixie (Heroku Add-on).

这篇关于使用mongoose和Fixie连接到mongodb(Heroku附加组件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆