Running mobile app in device, problems connecting with server

Hi, I had a bad surprise this morning when testing my meteor app in my device (android LG3), yesterday night was working just fine, but today no data from the server is retrieved. I’m my index page I have a subscription.ready() eval that never goes true:

	if (!this.subscription.ready()){
		IonLoading.show();
	} else {
		IonLoading.hide();
	}

or for example form the login page it always get’s stuck without response.

If I try the same running either in android simulator or browser this just work fine, I’ve also tried to run specifying a given port: meteor run android-device --port 3002

Nothing seems to work, and the app gets frozen without logging anything, this is all I have:

=> Started proxy.                             
=> Started app on Android Device.             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3002/

Also I’ve noticed that if I open a browser window and point to the app url, and modify any code, while the browser reflects the changes the device does not.

I’m lost right now, deleted cordova-build and created again but it’s still the same problem, the device will install the app, but it’ll get stuck in the very first roundtrip to the server…

have you config the mobile-server args like --mobile-server ip:port to run the app for you mobile

not really I was just running like this: meteor run android-device --port 3002, can you point out the instruction please?

i just run like :meteor run android-device --port ip:port --mobile-server ip:port
then the mobile know where is the meteor server.

you can use: meteor run --help to see the detail.
–mobile-server Location where mobile builds connect to the Meteor server.
Defaults to your local IP and the port that the Meteor
server binds to. Can include a URL scheme (for
example, --mobile-server=https://example.com:443).

Unfortunately I have the same results with: meteor run android-device --port 3002 --mobile-server=http://localhost:3002 :pensive:

it usually happens when your new hot code update has screwed something. It can be fixed with deleting all data in the app.

you can not use --mobile-server=http://localhost:3002. because in your mobile localhost is unknow. others make sure you moblie and your meteor in the same network.

Right, I did not even see it is localhost. There is no server on a phone, so no localhost. Mobile server needs to be pointed to your development or production server

Hey
stubborncoder
i also stuck on this same issue which you mentioned , so have you found any way to solve it? If yes , then please provide me some instruction.

Thanks

Hi, i have the same problem and i do: meteor run ios-device --mobile-server http://192.168.2.126:3000
It works fie, but if i do an update of the code of my app the refresh on the apps start but i have an error:

Failed to load resource: Could not connect to the server. http://localhost:3000/sockjs/info?cb=fpbx3y94_g

Why? It seems like my apps lost correct url to server and refresh set default localhost as server for my app…

Hi Moreschisimone - I am getting the same error. Do you have any guidance to share

Regards,
Naveen Jindal

Yes, i solved it in this way:

  1. in code i put this code:

if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
process.env.MOBILE_DDP_URL = ‘http://1.1.1.1:3000’;
process.env.MOBILE_ROOT_URL = ‘http://1.1.1.1:3000’;
});
}

then…

  1. compile app: meteor run ios-device --web-server=http://1.1.1.1:3000

I never get this error again! :smile:

I think code n step 1 is send to client on hot code refresh and helps app to understand where to connect on reload.
Second step is for the first connection of the app at startup.

I cannot found other way to make it works… is possible there is a better solution… but works :wink:

my project is deployed on live server, i want to make some customization, but it’s live so i am having same backup on mac and doing customization with localhost, i just put this code ( meteor run ios-device --mobile-server=http://localhost:3000 --production ) in run-mobile.sh
and i ran same command ( meteor run ios-device --mobile-server=http://localhost:3000 --production ) in meteor directory.

My application is getting open in xcode simulator and running good, but i am unable to see my customized code, it still showing codes coming from server, I want run ios app with localhost not with live server.
Is there need to be put any other file, or i need to change that file which i did not find, so where i can found that to set localhost.
Please suggest me on this.

This more recent GitHub issue states that MOBILE_DDP_URL and MOBILE_ROOT_URL are no longer valid. Should be using command line --mobile-server and --server options.

The latest list of supported environment variables shows the same.