I have an android application that does a GET Request to ASP.NET WEBAPI service i have created the service and it works when you open in browser while using II Express. However the application in my android device() is unable to reach the Service i created i'm using URL:http:/localhost:8306/api/uconnectservice and the LOGCAT recieved is as follows: java.net.SocketTimeoutException: failed to connect to /localhost(port 8306) after 10000ms. I have activated IIS7 and have tried looking over the NET.I don't know if it is server configuration issue.Pls any help or guidance needed thnx My Code For Android: String URL = "http://localhost:8306/api/uconnectservice";
private final OkHttpClient client = new OkHttpClient();
public void run() throws Exception {
Request request = new Request.Builder().url(URL).build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@SuppressLint("NewApi")
@Override
public void onResponse(Call call, Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);
Headers responseHeaders = response.headers();
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
Log.e("Results", responseBody.string());
}
}
});
}
/////////////////////CODE FOR SERVER ASP.NET WEBAPI////////////////////
namespace UnicsPlcServices.Controllers
{
public class UConnectServiceController : ApiController
{
private IUconnectRepository _UconnectHandler;
public UConnectServiceController()
{
_UconnectHandler = new UconnectRepository();
}
public UConnectServiceController(IUconnectRepository repository)
{
if (_UconnectHandler == null)
{
throw new ArgumentNullException("repository");
}
_UconnectHandler = repository;
}
// GET api/uconnectservice
public List<AcountTypesRegistered> Get()
{
return _UconnectHandler.GetAll();
}
.........................other code`enter code here`