Connection Refused - HTTPClient
I doubt this is related to titanium. I am using MAMP and I am trying to access a PHP file. It works fine in the iPhone emulator, but if I try it on the android emulator, I get a connection refused error in my onerror method. Anyone know why this is happening?
9 Answers
-
From http://developer.android.com/resources/faq/commontasks.html#localhostalias
> If you need to refer to your host computer's localhost, such as when you want the emulator client to contact a server running on the same host, use the alias 10.0.2.2 to refer to the host computer's loopback interface. From the emulator's perspective, localhost (127.0.0.1) refers to its own loopback interface.
You'll need to point to your actual IP address, your internal internal IP address, or 10.0.2.2
-
Are you using MAMP? I figured mine out today actually. In the MAMP prefs,under the ports tab, I hit 'use default ports' and it sets the apache port to 80.
Now when you make calls use your local ip address without a port number. ex: http://192.168.1.157/yourfile.php -
Hmm ok.. Not doing anything out of the ordinary here. Works on the iphone, fails on the android emulator
loginBtn.addEventListener('click',function(e) { if (username.value != '' && password.value != '') { loginReq.open("POST","http://localhost:8888/post_auth.php"); var params = { username: username.value, password: Ti.Utils.md5HexDigest(password.value) }; loginReq.send(params); } else { alert("Username/Password are required"); } });
-
I am still searching for this answer if anyone has any idea?
-
Localhost is the issue here, it doesn't work on Android for some reasons, mapped internally.
-
well since localhost is the issue, I changed it to my internal IP http://192.168.1.157:8888/post_auth.php and it is now crashing the application (on android, iphone still works)…hmmm
-
I'm having the same problem on android emulator (when trying to establish a connection to localhost via HTTPClient); I keep getting connection refused. Does anyone have a solution?
-
I'm Getting the same issue!! On Android Emulator i can't open a HTTPClient with localhost. I haven't test with iPhone because I dont have Mac.
Any solution?!Thanks!
-
Sending error Connection to http://localhost:8888 refused
how can i solved?