Android连接远程服务器

02-17 03:46:53.844: WARN/System.err(717): org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:8080 refused 02-17 03:46:53.894: WARN/System.err(717): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:133) 02-17 03:46:53.934: WARN/System.err(717): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 02-17 03:46:53.944: WARN/System.err(717): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 02-17 03:46:53.964: WARN/System.err(717): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348) 02-17 03:46:53.975: WARN/System.err(717): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 02-17 03:46:53.985: WARN/System.err(717): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 02-17 03:46:53.995: WARN/System.err(717): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)

出现这个错误是因为,我在测试的时候将模拟器要连接的本地网址写成了127.0.0.1,android模拟器(simulator)把它自己作为了localhost,也就是说,代码中使用localhost或者127.0.0.1来访问,都是访问模拟器自己,所以自然访问不到想要的地址了。

你可能感兴趣的:(android,测试,服务器)