meteor android app不会连接到服务器(meteor android app won't connect to server)

编程入门 行业动态 更新时间:2024-10-27 10:23:40
meteor android app不会连接到服务器(meteor android app won't connect to server)

我有一个多人宾果游戏,我制作并将其托管在Modulus上。 将项目上传到Modulus并为我的项目安装他们的MongoDB之后,多人游戏在浏览器上工作得很好,但是当我尝试meteor构建游戏并获得android .apk文件安装在我的魅族设备上时安装中止了并告诉我一个解析错误,所以我决定将整个项目导入android studio并从那里构建apk文件。 从Android Studio安装apk后,应用程序打开,但它似乎没有与Modulus托管服务器/ Modulus数据库的连接。 任何人都可以帮我指出我的错误吗? build命令是:

meteor build ../pathToBuild --server serverAdress

任何帮助?

I have a multiplayer bingo game which I made and im hosting it over Modulus. After uploading the project to Modulus and installing their MongoDB for my project, the multiplayer game works good over the browser, BUT, when I tried to meteor build the game and get the android .apk file to install over my Meizu device the installation got aborted and threw me a parse error so I decided to import the whole project to android studio and build the apk file from there. After installing the apk from Android Studio the application opens up, but it seems that it has no connection to the Modulus hosting server / Modulus db. Can anyone help and point me out my mistakes which I did? the build command was:

meteor build ../pathToBuild --server serverAdress

any help?

最满意答案

这通常与服务器的启动方式而不是应用程序有关,请尝试在运行要将应用程序连接到的服务器时使用与构建服务器相同的地址指定--mobile-server:

meteor --mobile-server http:/app.server:port

如果这样做或者您没有直接使用meteor命令运行应用程序,那么您可以在运行的服务器目录上设置DDP_DEFAULT_CONNECTION_URL环境变量,以避免每次运行应用程序时都必须指定它。

或者我想如果你升级到meteor 1.3并重建/部署,那么这个bug应该会消失。

关于这个帖子的更多信息,虽然它很长,还有一些其他的东西可以影响到这里,但这个方法适用于我的cordova Android应用程序。

well I solved this by hard coding the server's path inside the code

var theURL = "http://myServer"; if (process.env.NODE_ENV === "development") { // home theURL = "http://myServer"; // office //theURL = "http://192.168.10.30:3000"; } Meteor.absoluteUrl.defaultOptions.rootUrl = theURL; process.env.ROOT_URL = theURL; process.env.MOBILE_ROOT_URL = theURL; process.env.MOBILE_DDP_URL = theURL; process.env.DDP_DEFAULT_CONNECTION_URL = theURL;

did the trick for me

更多推荐

本文发布于:2023-08-07 04:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1461178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   服务器   android   meteor   app

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!