【问题标题】:can't connect to hosted or local mongo on meteor android-device无法连接到流星 android-device 上的托管或本地 mongo
【发布时间】:2020-10-14 05:27:16
【问题描述】:

meteor run android-device 上运行时,基本上我无法让本地或托管的 mongo 连接到我的应用程序。只需meteor run,本地和托管都可以正常工作。我也无法让它在为测试 Play 商店而发布的应用程序上运行,但我假设一旦我能够在本地运行我托管的 mongo,我应该能够将这些修复应用到已发布的版本。我正在运行 ubuntu 18.04。


在我的 Android 手机上进行本地测试时连接到我的本地 mongo:
所以根据我在网上阅读的内容,设备和计算机需要在同一个 wifi 网络上,我需要声明 --mobile-server。 我的手机处于飞行模式,连接到 wifi 网络并插入我的笔记本电脑进行测试。我不认为这是防火墙问题,因为我有其他硬件我正在以这种方式连接到工作。 这些是我尝试过的各种脚本,但都不起作用。我完全不知所措!我正在运行最新的流星。粗体字我也在模拟器上试过。

"android-device-local": "MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 192.168.0.102"

"android-device-local": "MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 192.168.0.102:3000"

"android-device-local": "MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server locahost:3000"

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server locahost:27017”

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 127.0.0.1”

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 127.0.0.1:27017”

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 127.0.0.1:3000”

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 192.168.0.109” <-- ip address of my phone on my wifi network

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server 192.168.0.109:3000”

“android-device-local”: “MONGO_URL=mongodb://:@localhost:27017/dbName meteor run android-device --mobile-server localhost:12816” <-- chrome’s remote debugging url


连接到我托管的 mongo (mongodb.com)
我明白这里的--mobile-server 将是一个托管您的应用程序的在线服务器,但这是我感到困惑的地方……如果它托管在 Play 商店中,这究竟是什么意思?我有一个个人网站(在 google 上注册的域,托管在 aws amplify 上),为此我使用了一个子域。

我已经完成了本指南https://sergelobatch.com/beginners-guide-to-deploying-a-meteor-app-to-an-aws-server-with-meteor-up/,并且能够通过 ec2 公共 ipv4 地址和通过我的 Web 浏览器的子域访问该应用程序,它按预期从数据库中提取数据。我已经允许我的 ec2 的公共 ipv4 访问我的 mongodb 网络。 (旁注,不是https,有关系吗?)

再次在本地运行,我尝试了这些,仍然没有运气:

“MONGO_URL=<mongodb.net_connection_string> meteor run android-device --mobile-server <ec2_public_ipv4>:80”

“MONGO_URL=<mongodb.net_connection_string> meteor run android-device --mobile-server <ec2_public_ipv4>:3000”

“MONGO_URL=<mongodb.net_connection_string> meteor run android-device --mobile-server http://<ec2_public_ipv4>:80”

^^^ 我已经用 ROOT_URL=sub.domain.com 尝试了以上所有方法

“MONGO_URL=<mongodb.net_connection_string> meteor run android-device --mobile-server sub.domain.com”

“MONGO_URL=<mongodb.net_connection_string> meteor run android-device --mobile-server sub.domain.com:80”


更新: 我确实看到我没有找到一些科尔多瓦资产。即使在手动添加这些包之后,它们仍然存在。


I20200624-01:28:29.236(-7)? 06-24 01:28:27.889  6311  6393 W MeteorWebApp: Asset /cordova_plugins.js not found in bundle 7f92647871b290270da17a1a34abfb1f0d9c1cda:file:///android_asset/www/application, no parent bundle

I20200624-01:28:29.236(-7)? 06-24 01:28:27.914  6311  6401 W MeteorWebApp: Asset /plugins/cordova-plugin-splashscreen/www/splashscreen.js not found in bundle 7f92647871b290270da17a1a34abfb1f0d9c1cda:file:///android_asset/www/application, no parent bundle

I20200624-01:28:29.236(-7)? 06-24 01:28:27.914  6311  6404 W MeteorWebApp: Asset /plugins/cordova-plugin-meteor-webapp/www/webapp_local_server.js not found in bundle 7f92647871b290270da17a1a34abfb1f0d9c1cda:file:///android_asset/www/application, no parent bundle

I20200624-01:28:29.236(-7)? 06-24 01:28:27.915  6311  6393 W MeteorWebApp: Asset /plugins/cordova-plugin-statusbar/www/statusbar.js not found in bundle



移动配置.js

    App.info({
        //
    });
    
    App.icons({
      'android_mdpi': 'resources/icons/icon-48x48.png',
      'android_hdpi': 'resources/icons/icon-72x72.png',
      'android_xhdpi': 'resources/icons/icon-96x96.png',
      'android_xxhdpi': 'resources/icons/icon-148x148.png',
      'android_xxxhdpi': 'resources/icons/icon-192x192.png'
    });
    
    App.launchScreens({
      // Android
      'android_mdpi_portrait': 'resources/splash/splash-320x480.png',
      'android_mdpi_landscape': 'resources/splash/splash-480x320.png',
      'android_hdpi_portrait': 'resources/splash/splash-480x800.png',
      'android_hdpi_landscape': 'resources/splash/splash-800x480.png',
      'android_xhdpi_portrait': 'resources/splash/splash-720x1280.png',
      'android_xhdpi_landscape': 'resources/splash/splash-1280x720.png'
    });
    
    App.accessRule("*");
    App.accessRule("http://")
    App.accessRule("https://")
    App.accessRule("http://localhost:*")
    App.accessRule("http://127.0.0.1:*")
    App.accessRule("http://127.0.0.1")
    App.accessRule('http://localhost:3000/*');
    App.accessRule('http://192.168.1.109:3000/*');
    App.accessRule('http://192.168.1.102:3000/*');
    App.accessRule('http://<subdomain>.<domain>.com/*');
    App.accessRule('http://localhost:3000/*');
    App.accessRule('http://<ec2 public ipv4>/*');
    App.accessRule('http://<ec2 public ipv4>:*');

【问题讨论】:

  • 为问题的所有尝试添加错误消息。
  • 没有,数据库根本没有建立连接。除了我在其中运行应用程序的终端之外,还有其他地方可以查看吗?
  • 啊我错了我发现了一个可能的问题,正在更新我的帖子
  • 我不知道捆绑错误是怎么回事。至于连接错误,您应该会收到来自您正在使用的驱动程序的诊断信息。如果不这样做,请查阅驱动程序文档以了解如何增加详细程度。
  • 您能否添加用于构建应用程序以进行部署的 shellscript 以及您的移动配置 json?

标签: android mongodb cordova meteor amazon-ec2


【解决方案1】:

供将来参考:修复是通过 https://docs.meteor.com/packages/autoupdate.html 添加自动更新和必要的配置,并使用标志 --mobile server &lt;ec2-public-ipv4&gt;:80 运行 dev 并使用 --server &lt;ec2-public-ipv4&gt;:80 运行构建

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-01
    • 2018-11-13
    • 2015-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 2016-12-23
    相关资源
    最近更新 更多