【问题标题】:How to connect an android application to a self-hosted Parse.com server?如何将 android 应用程序连接到自托管 Parse.com 服务器?
【发布时间】:2016-07-15 01:21:51
【问题描述】:

我有一个 Amazon EC2 Ubuntu 实例,其中包含来自 GitHub project 的 MongoDB、Node.JS 和 Parse Server 示例。

我已将 Parse.com 迁移到实例上的 MongoDB。它的地址是mongodb://usr:****@xxx.xxx.xxx.xxx:27017/euro

我已经在/var/www/parse 中安装了来自 GitHub 的 Parse Server 示例。
当我运行服务器时,我收到以下消息:

$ cd /var/www/parse
$ npm run start

> parse-server-example@1.4.0 start /var/www/parse
> node index.js

DATABASE_URI not specified, falling back to localhost.
parse-server-example running on port 1337.
Parse LiveQuery Server starts running.

我的问题是什么指向localhost?公共DNS?公网IP?

如何在 Android 应用中使用此代码连接到服务器?

Parse.initialize(new Parse.Configuration.Builder(myContext)
    .applicationId("YOUR_APP_ID")
    .server("http://YOUR_PARSE_SERVER:1337/parse")
    .build()
);

当我尝试使用此地址 http://ec2-xxx-xxx-xxx-xxx.compute-x.amazonaws.com:1337/parse(公共 DNS)通过浏览器打开它时,我收到一条消息说连接已停止。

当我尝试使用此地址 http://xxx.xxx.xxx.xxx:1337/parse(公共 IP)通过浏览器打开它时,我收到一条消息说连接已停止。

【问题讨论】:

  • 在你的安全组中打开端口?
  • 是的,我确实打开了端口

标签: android mongodb parse-platform amazon-ec2


【解决方案1】:

localhost127.0.0.1 的别名。这是您的loopback 地址。
它只能在本地访问。

localhost 维基百科

【讨论】:

  • 我的问题是如何从不在同一个网络上的计算机指向这个地址。
  • 你不能,它是locahost。但是您的服务器正在侦听您的计算机地址IP。该警告仅告诉您它正在localhost 上连接到 MongoDB。
  • 我想你没有理解我的问题。本地主机位于 EC2 实例上。我想知道如何从我的计算机上指向这个地址。
  • 您必须找到您的 EC2 实例的 DNS 条目的地址 IP。我不知道亚马逊是如何做到这一点的。对不起!
猜你喜欢
  • 2017-06-04
  • 1970-01-01
  • 2020-12-01
  • 2015-10-17
  • 2012-09-19
  • 2017-11-21
  • 2017-11-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多