[英]Getting 502 Bad Gateway: Registered endpoint failed to handle the request when tried to connect mongodb using node js in PCF platform
I have mongodb in AWS EC2 instance . 我在AWS EC2实例中有mongodb 。
I am trying to connec to mongodb instance from nodejs server using mongoClient . 我正在尝试使用mongoClient从nodejs服务器连接到mongodb实例。 My node application is deployed on PCF platform.
我的节点应用程序已部署在PCF平台上。
When i try to connect to mongodb 当我尝试连接到mongodb
it throws an error " 502 Bad Gateway : 它抛出错误“ 502 Bad Gateway :
Registered endpoint failed to handle the request". My node application is working fine, one the connection with mongodb is causing the problem. 注册的端点无法处理该请求。”我的节点应用程序运行正常,与mongodb的连接之一导致了问题。
conn_str += req.params.dbname;
mongoClient.connect(conn_str, function(err, db) {
if(err) {
res.end(err);
} else {
res.end(db);
}
});
Help much appreciated. 帮助非常感谢。
Ok. 好。 I had faced a similar issue while I was trying to connect to my mongo cluster which was deployed on Google Compute Engine.
当我尝试连接到部署在Google Compute Engine上的mongo群集时,我遇到了类似的问题。 The below checklist helped me resolve the issue
以下清单帮助我解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.