[英]Where to find appID and masterkey when mongoDB is installed on AWS EC2 Machine. Parse Server
I have mongoDB installed on AWS EC2 instance from where I am trying to connect Parse Server installed on my local pc. 我在试图连接本地PC上安装的Parse Server的AWS EC2实例上安装了mongoDB。 when I try to connect parse server to parse.com apps using their appid and masterkey it just works fine.
当我尝试使用appid和masterkey将parse服务器连接到parse.com应用时,它工作正常。 but when I try to connect to my mongoDB instance on EC2 then it says "Server not reachable: unable to connect to server".
但是当我尝试连接到EC2上的mongoDB实例时,它显示“服务器无法访问:无法连接到服务器”。
I already started the server using mongod command on the terminal. 我已经在终端上使用mongod命令启动了服务器。 I checked the securityGroup it is open to all requests.
我检查了securityGroup,它对所有请求都是开放的。 I checked the database it exist with data in it.
我检查了数据库中是否存在数据。 I have the following code in configuration file to connect
我在配置文件中有以下代码可以连接
{
"apps": [
{
"serverURL": "https://api.parse.com/1",
"appId": "TWxCk7***************************JZ32k3",
"masterKey": "S*********t3234*******************i",
"appName": "ParseServer"
},
{
"serverURL": "https://api.parse.com/1",
"appId": "x544******************4343************SPtRO",
"masterKey": "8B4******************Y32fkiiU782IL",
"appName": "ParseServer 2"
},
{
"serverURL": "http://dbuser:Password@ec2-**4-2**-**4-1*9.compute-1.amazonaws.com:27017/db",
"appId": "x544******************4343************SPtRO",
"masterKey": "8B4******************Y32fkiiU782IL",
"appName": "AWS"
}
]
}
Note: ParseServer2 and AWS apps have same key because the db on EC2 is migrated from it. 注意:ParseServer2和AWS应用程序具有相同的密钥,因为EC2上的数据库已从其中迁移。
in parse server appId and masterKey are configured in the code where you initialize the ParseServer instance. 在解析服务器中,在初始化ParseServer实例的代码中配置了appId和masterKey。
Go to you parse-server project open index.js and take the appId and masterKey from there.. 转到您的parse-server项目,打开index.js并从那里获取appId和masterKey。
var express = require('express'); var ParseServer = require('parse-server').ParseServer; var app = express(); var api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code appId: 'myAppId', masterKey: 'myMasterKey', // Keep this key secret! fileKey: 'optionalFileKey', serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed }); // Serve the Parse API on the /parse URL prefix app.use('/parse', api); app.listen(1337, function() { console.log('parse-server-example running on port 1337.'); });
There you can see your appId and masterKey copy those values and paste them to your dashboard config. 在那里,您可以看到appId和masterKey复制这些值并将其粘贴到仪表板配置中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.