Seems like everyone have issue accessing local machine or internet etc from emulator. All that works for me. Now I got my WCF service installed on my home server, port opened and I can browse just fine with a browser.
I changed URL in emulator, pointed to “real” server and it WORKS. Now, I installed app on device and it times out connecting to server (10 seconds). What do I miss?
Server is IIS7.5 with .NET WCF REST service. Device connected to 3G and I can browse my own site from web browser on device but in code it fails. Code looks like so and my url like “http://domain:8080/mobile/auth”
EDIT: Tried on another phone and it WORKS! What can be a problem? My phone is Nexus S with 2.3, I target 2.2 and my emulator 2.2 And my other phone (which works) also 2.2
Also, one phone on TMobile and another on Sprint. Is that weird issue?
EDIT 2:
Some Google search.. It might be related to T-Mobile blocking port 8080. I do post specifically and when I browse via browser it does GET, so maybe my issue there. I will try on another T-Mobile phone tomorrow.
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT);
HttpClient client = new DefaultHttpClient(httpParams);
HttpPost request = new HttpPost(url);
try
{
StringEntity entity = new StringEntity(requestData);
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(entity);
ResponseHandler<String> handler = new BasicResponseHandler();
returnData = client.execute(request, handler);
}
catch (Throwable e)
{
String s = e.getMessage();
//TODO: Log exception on device
}
Sure looks like you answered your own question there:
If you’re not getting an exception, then it sounds very much like a DNS problem. Try connecting to your local network via wifi and see if that eliminates the problem.