Domanda

I am doing this tutorial with some differences.

But i am having some problems. First i was having IIS(Internet Information Services) so i changed the httpd.conf to the port 8080.

On the android program I set the url to:

localhost/android_connect/get_all_products.php

But i cannot run the program.It keeps giving me errors on

HttpResponse httpResponse = httpClient.execute(httpGet);

My log is giving me this errors:

03-21 05:56:24.864: D/libc-netbsd(3966): getaddrinfo: localhost  return error = 0x8 >>

03-21 05:56:24.867: D/libc-netbsd(3966): getaddrinfo: localhost get result from proxy >>

03-21 05:56:24.869: I/System.out(3966): [socket][0] connection /127.0.0.1:8080;LocalPort=60338(0)

03-21 05:56:24.870: I/System.out(3966): [CDS]connect[/127.0.0.1:8080] tm:90

03-21 05:56:24.871: D/Posix(3966): [Posix_connect Debug]Process com.example.oss :8080 

03-21 05:56:24.873: I/System.out(3966): [socket][1:60338] exception

03-21 05:56:24.875: I/System.out(3966): [CDS]close[60338]

03-21 05:56:24.877: I/System.out(3966): close [socket][/0.0.0.0:60338]

03-21 05:56:24.880: W/System.err(3966): org.apache.http.conn.HttpHostConnectException: Connection to localhost:8080 refused

03-21 05:56:24.881: W/System.err(3966):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)

Can anyone help me?

È stato utile?

Soluzione

At first, I guess you are running your application on an emulator so actually the localhost now pointing to you emulator which is not the server. Therefore, the connection can't be established and cause the error.

Instead of using localhost or 127.0.0.1 as your server address, try using your PC IP as the server address, you can find the IP on the cmd with the command: ipconfig /all

Hope this help.

Altri suggerimenti

you may try 10.0.2.2 instead of 127.0.0.1.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top