[英]Connect to EC2 AWS mongoDB server using PHP from Godaddy
So I have setup a Bitnami EC2 mongoDB server. 因此,我已经安装了Bitnami EC2 mongoDB服务器。 It is running, I can connect to it locally and I have inserted some documents and I am able to see my database and the documents using MongoDB Compass (through SSH tunnel).
它正在运行,我可以在本地连接到它,并且已经插入了一些文档,并且能够使用MongoDB Compass(通过SSH隧道)查看我的数据库和文档。 In the security group of my EC2 instance I allow all traffic from all ports (for test purposes).
在我的EC2实例的安全组中,我允许来自所有端口的所有流量(出于测试目的)。 I have commented out also the bind_ip from the mongod.config file.
我也从mongod.config文件中注释了bind_ip。 However when running the following code
但是,当运行以下代码时
<?php
$key = '1234';
$m = new MongoClient("mongodb://xx.xxx.xx.xxx", array("username" => $bitnami",
"password" => $key));
?>
I get the following error "Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: xx.xxx.xx.xxx:27017: Connection refused'" 我收到以下错误“致命错误:未捕获的异常'MongoConnectionException',并显示消息'无法连接至:xx.xxx.xx.xxx:27017:连接被拒绝'”
I have searched for possible answers and asked a similar question in stackoverflow before but it solved my problem only partially. 之前我已经搜索了可能的答案并在stackoverflow中提出了类似的问题,但是它只能部分解决我的问题。 I know the MongoClient command is deprecated but using the MongoDB\\Driver\\Manager I also cannot connect and no error message is shown.
我知道MongoClient命令已弃用,但使用MongoDB \\ Driver \\ Manager我也无法连接,并且未显示任何错误消息。 I hope somebody can help me with this, thanks in advance!
我希望有人可以帮助我,在此先感谢!
Godaddy restricts outgoing connection ports so you cannot connect from Godaddy to EC2. Godaddy限制了传出连接端口,因此您无法从Godaddy连接到EC2。
Other useful references: 其他有用的参考资料:
https://godaddy.pissedconsumer.com/they-can-t-even-open-a-port-for-outgoing-connections-ridiculous-20140923537475.html https://godaddy.pissedconsumer.com/they-can-t-even-open-a-port-for-outgoing-connections-ridiculous-20140923537475.html
https://www.godaddy.com/community/Developer-Cloud-Portal/vps-outbound-port-restriction/td-p/3770 https://www.godaddy.com/community/Developer-Cloud-Portal/vps-outbound-port-restriction/td-p/3770
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.