title: Restlet for Android: Internal Connector Error (1002) - Calling thread time out error
body: <p>I am writing a simple android application that talks to a restful web-service hosted on google app engine. The web service is developed using the Restlet framework. Here are the details of my environment:</p>
  
  <ul>
  <li>Server Side: Restlet v2.0.3 for GAE</li>
  <li>Android Side: Restlet v2.0.3 for</li>
  <li>Android Android: v2.2 API Level 8</li>
  </ul>
  
  <p>I am placed the following permission in my AndroidManifest.xml:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt; 
  </code></pre>
  
  <p>At first, when I was developing the web service on my local development server, I was able to access this web service from within the Restlet client of my android app without any issues.</p>
  
  <p>A few days back, I uploaded my service to the GAE's appspot and recompiled my android app with this new url. However, this time my app does not seem to connect to this web service at all. It attempts to connect and blocks for about a minute or so and throws up this error in the logcat:</p>
  
  <pre><code>12-27 15:14:52.856: ERROR/MyActivity(362): Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it.
  12-27 15:14:52.856: ERROR/MyActivity(362):     at org.restlet.resource.ClientResource$1.invoke(ClientResource.java:1648)
  12-27 15:14:52.856: ERROR/MyActivity(362):     at $Proxy7.getAvailableItems(Native Method)
  12-27 15:14:52.856: ERROR/MyActivity(362):     at com.example.activities.MyActivity$1.run(MyActivity.java:94)
  </code></pre>
  
  <p>I am calling the following web service method on GAE:</p>
  
  <pre><code>@Get
  GetItemsResponse getAvailableItems(ItemCategory itemCategory);
  </code></pre>
  
  <p>Moreover, I am doing this on the android side to bind to the web service:</p>
  
  <pre><code>    ClientResource clientResource = new ClientResource(myServiceUri);
      return clientResource.wrap(ItemsResource.class);
  </code></pre>
  
  <p>Note that the appspot-based web service is working fine. I am able to access the service from the browser outside. It also properly serves a .jsp file that is part of my application war and I'm able to use it.</p>
  
  <p>On the other hand, during the time when the android app tries to connect to this service, I do not even see any incoming request log in my appspot dashboard. Seems like the android request isn't even reaching GAE for some reason.</p>
  
  <p>Here's how I make the web service call on the android side...</p>
  
  <ol>
  <li>The call to the web service occurs on a <em>Thread</em> with default priority.</li>
  <li>This thread is spawned &amp; started inside the <em>onStart</em> method of my main activity.</li>
  <li>Meanwhile, I render a progress dialog on the UI thread.</li>
  <li>Once the thread receives any response from the web service, it updates the <em>SharedPreferences</em> with a certain value. If the call returns any error, it logs this error and then updates <em>SharedPreferences</em> with a default value.</li>
  <li>This causes my <em>SharedPreferences</em> listener to be invoked. It then cancels the progress dialog and renders the main UI.</li>
  </ol>
  
  <p>Ever since I moved this service to appspot, the thread always returns with the exception I mentioned above.</p>
  
  <p>Am I doing something wrong here ? Why does the call to this service fail when I access it from appspot ? Please let me know if you need more information. </p>
  
  <p>-Kalyan Akella</p>