tags:

views:

49

answers:

2

I am trying to comsume a self-hosted WCF service which simply returns a String in JSON format. It takes a very long time around 2-3 minutes to get the response on Android Device, where as on any other computer it works fine. Could anyone help me on this? Thanks in Advance.

Below is my code to access the service.

 try{

 HttpClient httpclient = new DefaultHttpClient();
 HttpGet request = new HttpGet("http://192.168.1.83:8000/GetOffers");
 ResponseHandler<String> handler = new BasicResponseHandler();
 //you result will be String :
 result = httpclient.execute(request, handler);


   } catch (ClientProtocolException e) {
   // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (IOException e) {
    // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (JSONException e) {
    // TODO Auto-generated catch block
   e.printStackTrace();
 }
A: 

Are you sure your phone's connection is fast enough? Also I think you are testing locally so getting stuff on the computer would be very fast. Fetching things from the actual server would be slow. I use the same code and works for me pretty well when I'm on a wi-fi connection.

Abhinav
Thanks for your response, yes I am testing it on other computers connected to LAN and my android phone is too connected to LAN through Wi-Fi. My current scenario is to just enable the phone to acccess my locally available wcf service. Does it make any difference in speed and connectivity issues if the wcf service is self-hosted rather than IIS-hosted? I am not sure. I am struggling get it worked. Thanks.
Shafi
A: 

Ironically, I was suspecting Windows Defender for slower response and I was right. Once I disabled it and restarted the server, everything seems to be working fine. I don't know what was causing Windows Defender to slow down WCF service response. Anyways, I am up and running now. Abhinav...You were right, there was no problem at client side. Thanks anyways.

Shafi
Great. Am a Linux/Mac guy but turning the computer on and off again always works. :)
Abhinav