delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Local Server #46

Closed rafaelcorreiapoli closed 8 years ago

rafaelcorreiapoli commented 8 years ago

Hello! I set up a simple meteor server on localhost It's fine when accessing via browser: http://localhost:3000

I tried to connect from my android client and the connection is refused mMeteor = new Meteor(getApplicationContext(), "ws://localhost:3000/websocket");

12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out: Meteor
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out:   onClose
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out:     code == 2
12-17 19:37:23.738 650-650/com.example.rafa93br.meteorddp2 I/System.out:     reason == failed to connect to localhost/127.0.0.1 (port 3000) after 6000ms: isConnected failed: ECONNREFUSED (Connection refused)

I tried to connect to android-ddp-meteor.meteor.com and it worked just fine, so I think that the problem is with my server, is there any permissions i should there to allow android clients to connect?

kaoskeya commented 8 years ago

Make sure your development machine and phone are on the same network and find the local IP of your dev machine and put that IP in place of 'localhost'. The localhost:3000 is accessible only from the same machine on which the meteor server is running.

Use ifconfig/ipconfig depending on your environment to find your local IP.

ocram commented 8 years ago

@kaoskeya Thanks for your help!

@rafaelcorreiapoli Did this work for you? The target localhost probably only works if you're running the app on the emulator. What do you use, emulator or real device?

rafaelcorreiapoli commented 8 years ago

Hello! I was running on emulator, so i thought that emulator would treat localhost as my ubuntu, but I forgot that the emulator is an operating system itself, so localhost for the emulator is the android OS =P It worked with my Local network ip address (192.168...) Thanks!