Problem with connecting mobile Cordova app to local server

Since today, my mobile apps are not able to connect to my local development server any more. The app starts up, but as soon as I try to login (which triggers a socksjs call), the login dialog gets stuck.

On Android, I’m getting the following message:

XMLHttpRequest cannot load http://192.168.2.102/sockjs/info?cb=_ompx91vso. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://meteor.local' is therefore not allowed access. The response had HTTP status code 404.

iOS fails silently.

I’ve noticed that the IP address of my Mac has changed, so I had to adapt the --mobile-server option accordingly. And I also did an upgrade to Android M in the meantime, but as iOS is affected as well, I don’t think its related to that.

On iOS, I’ve already set the Allow Arbitrary Loads option which prevented connectivity earlier. But this did not help.

I also checked the config.xml file, and the access origin settings include these lines:

  <access origin="http://meteor.local/*"/>
  <access origin="*://192.168.2.102/*"/>

So I would assume that the origins are set correctly.

But despite of that, nothing works. Any ideas why the connection is broken now and how to fix that?

Do you have
App.accessRule(’*’);
in your mobile-config.js?

Yes, I added it, just to be sure.

I now restarted everything and even re-built the app. The origin message is gone, but I am still getting timeouts as soon as the client tries to access data from 192.168.2.102 via XHR on both devices.

It looks as if the client cannot connect to the Mac. It works, however, if I connect to the webapp using the device’s standard web-browser. Obviously, only the app cannot connect to the IP.

Have you tried removing the app from the devices?

There is an issue with the current hot code push implementation always using the latest downloaded app version instead of the one bundled with the app, and if the server’s IP address changes that means it will still try to connect to the old one.

Hi Martijn,

yes, I removed the apps from both devices – many times. I even re-started my PC to make sure everything is clean. I also tried meteor reset.

Still, the apps won’t connect.

Thanks for your help, Tom

Argh, I found the problem: When I was updating my startup scripts to match the new IP address, I typed 192.186… instead of 192.168… Completely my fault, sorry for bothering! That’s embarassing… :flushed:

No problem, glad to hear you got it working!