【发布时间】:2016-12-15 13:10:05
【问题描述】:
我在使用 android、ios 和 iOS 模拟器连接到我的服务器时遇到了一系列问题。经过几天的反复寻找解决此问题的方法。我每次都走得更近,但仍然无法完全连接。我有 Iron:Router,可以访问任何不需要登录的页面,但是一旦我尝试注册或登录,它就会“冻结”,并且在调试过程中它说它无法连接。
已尝试
1。具体 DDP_DEFAULT_CONNECTION
在 /server/lib/config.js 中
Meteor.startup(function() {
var theURL = "http://myUrl.com:3000";
if (process.env.NODE_ENV === "development") {
theURL = "http://101.ipaddress.0.0: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;
});
在对这些进行了一些修改之后,它随后将我转达给了一个 CORS 问题。我通过这样做解决了
2。 CORS 和 App.access
在 mobile-config.js 中
App.accessRule('http://*');
App.accessRule('https://*');
然后这给我带来了另一个与 iOS 安全传输相关的错误,我相信它是从 xcode 8 更新的?我解决了这个问题
3。更改应用传输安全设置
在 xCode 的 info 选项卡中:在 App Transport Security 下添加了“Allow Arbitrary Loads”:“true”
建议步骤
我还发现了一个不错的小块,可以控制日志连接状态。
if(Meteor.isClient){
Meteor.autorun(function () {
var stat;
if (Meteor.status().status === "connected") {
stat = 'lime'
}else if (Meteor.status().status === "connecting") {
stat = 'yellow'
}else {
stat = 'red';
}
Session.set('status',stat);
});
}
console.log(Session.get('status'));
这与注册按钮相关联,每次单击它都会触发状态。它一直是“红色的”。
Safari 调试器说我无法连接。
连接步骤
meteor run ios-device --mobile-server 101.ipaddress:3000
然后我点击运行按钮。我已阅读热代码推送问题,通常会删除 '.meteor/local/bundler-cache' && 'cordova-build'
我遇到了障碍,希望得到一些关于下一个解决方案的帮助/建议(或者我可能从根本上跳过了一些同时会非常烦人但又很快乐的事情)。
额外信息
Meteor 版本已尝试 1.2.1 和 1.3 mup.json
{
// Server authentication info
"servers": [
{
"host": "101.ipaddress.0.1",
"username": "username",
//"password": "password",
// or pem file (ssh based authentication)
// WARNING: Keys protected by a passphrase are not supported
"pem": "ssh/directory",
"pem": "ssh/directory",
"env": {}
}
],
// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,
// Application name (no spaces).
"appName": "AppName",
// Location of app (local directory). This can reference '~' as the users home directory.
// i.e., "app": "~/Meteor/my-app",
// This is the same as the line below.
"app": "/directory/to/app",
// Configure environment
// ROOT_URL must be set to your correct domain (https or http)
"env": {
"PORT": 80,
"ROOT_URL": "http://domainNameURL.com",
"MOBILE_ROOT_URL": "http://domainNameURL.com"
},
// Meteor Up checks if the app comes online just after the deployment.
// Before mup checks that, it will wait for the number of seconds configured below.
"deployCheckWaitTime": 60,
// show a progress bar while uploading.
// Make it false when you deploy using a CI box.
"enableUploadProgressBar": true
}
【问题讨论】:
-
您无法发出 http 请求?
-
我无法使用移动设备或其各自的模拟器“注册”或“登录”。我可以在浏览器上这样做。所以我认为这是一个 DDP 连接问题。
标签: android ios cordova meteor mobile