且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android设备上运行时,滞留的流星如“待办事项”载入画面

更新时间:2023-01-26 08:08:29

Exapnding上imslavko的答案...

的移动设备下载intial模板和诸如此类的东西通过USB,但在此之后是尝试从服务器加载数据。在你的情况下,移动设备(或应该)连接到您的局域网通过Wifi,您的路由器提供。我也假设你的开发PC连接到该路由器。

现在服务器内的虚拟机这将使问题对于移动设备,看你的服务器上运行。该IP的虚拟机(在你的情况10.0.2.15)不直接从网络的其他部分,因为这只会看到您的主机的IP(可能是192.168.xx)进行访问。

在运行命令流星

运行Android设备-p 10.0.2.15:3000

您告诉您的仪器在那个IP启动Web服务器,但你也说的是移动设备,以寻找在该IP网络服务器(它不能看到如上文所述)。

所以,你该怎么办? 两件事情...

  1. 您需要的端口转发从来宾虚拟机的主机PC。做这个事情...
    1. 让您的PC主机的IP ......在windows下运行cmd,之后使用ipconfig ....保存
    2. 在您的客户端虚拟机获得使用ifconfig IP(你的情况10.0.2.15)
    3. 在您的客户端虚拟机,进入虚拟盒顶部菜单,然后Devices->网络 - >网络设置......在窗口中单击端口转发按钮。
    4. 在有步骤1,主机端口= 3000添加规则... HOSTIP =您的主机的IP,访客IP = IP从第2步,来宾端口= 3000 ....点击OK
    5. 接下来您需要告诉您的移动设备来寻找服务器上不同的IP比一个服务器在实际运行。现在,你要转发的网络服务器IP到您的PC主机,你希望设备看你的PC主机的IP

因此​​,新的命令会......

流星运行Android设备-p 10.0.2.15:3000 --mobile服务器192.168.XX:3000

Issue(s)

The Meteor "todos" example is stuck on the loading screen forever when I try to run it on an android device. As can be seen in the screenshot below, the following error message is shown:

Failed to load resource: net::ERR_ADDRESS_UNREACHABLE http://10.0.2.15:3000/sockjs/info?cb=...

Also the app indicates it is having trouble connecting. Is it possible this could be due a bug in the Cordova Meteor 1.0 release? Or am I missing some important configuration/setup step?

Setup / Configuration

System Setup

  • Meteor 1.0
  • Ubuntu 14.04 VM with VirtualBox 4.3.18
  • Motorola Droid Turbo (Android 4.4.4) with Developer Mode and USB debugging enabled
  • Chrome 38

Run these commands in the Linux terminal

  • meteor create --example todos
  • cd todos
  • ifconfig <------- gives inet addr:10.0.2.15
  • meteor run android-device –p 10.0.2.15:3000

Open Chrome DevTools

  • Wait until the "todos" app launches on my android device (it does launch but it doesn’t move past the loading screen).
  • Then open up Google Chrome and type "chrome://inspect" in the search bar.
  • Click on the "Inspect" link under the "Todos" app listed under my Android device connected via USB.

Exapnding on imslavko's answer...

The mobile device downloads the intial templates and whatnot over USB, but after that is tries to load the data from the server. In your case the, the mobile device is (or should be) connected to your LAN via Wifi, provided by your router. I'm also assuming your dev PC is connected to that router.

Now the server is running inside a VM which would make it problematic for the mobile device to see your server. The IP in the VM (in your case 10.0.2.15) is not directly accessible from the rest of the LAN which would only see the IP of your host computer (likely 192.168.x.x).

When you run the command meteor

run android-device –p 10.0.2.15:3000

you are telling your meter to start a webserver at that IP, but you are also telling the mobile device to look for the webserver at that IP (which it can't see as stated above).

So what do you do? 2 things...

  1. You will need to port forward from the guest VM to your Host PC. To do this...
    1. Get your host PCs IP... in windows run cmd, then ipconfig.... save that
    2. On your guest VM get the IP with ifconfig (in your case 10.0.2.15)
    3. On your guest VM, go to the Virtual Box menu at the top then Devices->Network->Network Settings... in that window click the "Port Forwarding" button.
    4. In there add a rule... HostIP = your hosts IP from step 1, Host Port = 3000, Guest IP = IP from step 2, Guest Port = 3000.... hit OK
    5. Next you need to tell your mobile device to look for the server on a different IP than the one the server is actually running on. Now that you are forwarding the webserver IP to your host PC you want the device to look at your host PC's IP

so the new command would be....

meteor run android-device –p 10.0.2.15:3000 --mobile-server 192.168.x.x:3000