Home > Net >  Connect Meteor Cordova built app to local server and Database
Connect Meteor Cordova built app to local server and Database

Time:10-23

im trying out my first Meteor Cordova app. My Meteor app was standalone and functions fine. Then I added the Cordova part. When I run the app with

meteor run android-device

everything works fine on my mobile device that is connected via usb cable and I can access my local database that is running on port 3001. This is where my question comes in , when I try to build the app using

meteor build buildfolder --server=http://127.0.0.1:3000

because that is where my meteor project starts up when I use meteor run, my app cant seem to connect.

I have the code Meteor.startup(function () { console.log(__meteor_runtime_config__.ROOT_URL); }); and on startup on the app it does say it is running on http://127.0.0.1:3000 but after that I keep getting the error GET http://127.0.0.1:3000/sockjs/info?cb=h_i9p49ua9 net::ERR_CONNECTION_REFUSED

I have been looking for documentation , but cant find any step by step instructions just to build an apk I can install on my Android device and connect to my local instance of Meteor on my pc as well as the database.

Just to add in my config.xml file i get this

CodePudding user response:

I think the issue is that your app will try to connect to 127.0.0.1, but that's localhost -- it's the phone itself! If you just want to try it locally get the local IP of your server (other than localhost/127.0.0.1). This is often 192.168.1.N for some N. Under linux you can use ip a to see all your IP addresses for all devices. Find the one for your ethernet or wifi connection (not lo). Use that IP. Your Android device, assuming it is on the same network, will be able to resolve that and connect to your server.

  • Related