title: Android - Jsoup - SocketTimeoutException
body: <p>I'm trying to develop an Android app which uses jsoup-1.7.1.jar core library. I included the jar-file as a library but now when I want to use it, I'll receive a SocketTimeoutException everytime.
  I'm working on Ubuntu 12.04, eclipse-juno Build id: 20120614-1722, emulator/avd has 100MB of sd, 512Ram and is on API-Level 16.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private EditText text;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      text = (EditText) findViewById(R.id.editText1);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.mainmenue, menu);
      return true;
  }
  
  public void onClick(View view) {
  
      //Yes I'm aware that this should not be done. I'm planing to use it in the AsyncTask
      //doInBackground method, but since it was not working there, I decided to track it
      //down here in the main-activity -&gt; so it's just for debug
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
  
  
      Document doc = null;
      String url1 = "http://213.165.64.71";
      String url2 = "http://www.google.com";
      try {
          doc = Jsoup.connect(url2).timeout(10*1000).get();
      } catch (SocketTimeoutException a) {
          Log.e("MyAPP", "Exception----------A!", a);
      } catch (Exception e) {
          Log.e("MyAPP", "Exception----------E!", e);
      }
      String title = doc.title();
      Log.i("MyAPP", "Title="+title);
  }
  }
  </code></pre>
  
  <p>Error-Log:</p>
  
  <pre><code>10-05 10:45:23.680: E/MyAPP(1433): Exception----------A!
  10-05 10:45:23.680: E/MyAPP(1433): java.net.SocketTimeoutException
  10-05 10:45:23.680: E/MyAPP(1433):  at java.net.PlainSocketImpl.read(PlainSocketImpl.java:491)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.io.InputStream.read(InputStream.java:163)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.io.BufferedInputStream.read(BufferedInputStream.java:227)
  10-05 10:45:23.680: E/MyAPP(1433):  at libcore.io.Streams.readAsciiLine(Streams.java:201)
  10-05 10:45:23.680: E/MyAPP(1433):  at libcore.net.http.ChunkedInputStream.readChunkSize(ChunkedInputStream.java:77)
  10-05 10:45:23.680: E/MyAPP(1433):  at libcore.net.http.ChunkedInputStream.read(ChunkedInputStream.java:47)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.io.InputStream.read(InputStream.java:163)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.DataUtil.readToByteBuffer(DataUtil.java:113)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:447)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:429)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:393)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:159)
  10-05 10:45:23.680: E/MyAPP(1433):  at org.jsoup.helper.HttpConnection.get(HttpConnection.java:148)
  10-05 10:45:23.680: E/MyAPP(1433):  at de.funkypopcorn.reggae_a_gwaan.MainActivity.onClick(MainActivity.java:58)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.lang.reflect.Method.invoke(Method.java:511)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.view.View$1.onClick(View.java:3586)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.view.View.performClick(View.java:4084)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.view.View$PerformClick.run(View.java:16966)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.os.Handler.handleCallback(Handler.java:615)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.os.Handler.dispatchMessage(Handler.java:92)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.os.Looper.loop(Looper.java:137)
  10-05 10:45:23.680: E/MyAPP(1433):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 10:45:23.680: E/MyAPP(1433):  at java.lang.reflect.Method.invoke(Method.java:511)
  10-05 10:45:23.680: E/MyAPP(1433):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  10-05 10:45:23.680: E/MyAPP(1433):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  10-05 10:45:23.680: E/MyAPP(1433):  at dalvik.system.NativeStart.main(Native Method)
  10-05 10:45:23.730: E/AndroidRuntime(1433): FATAL EXCEPTION: main
  10-05 10:45:23.730: E/AndroidRuntime(1433): java.lang.IllegalStateException: Could not execute method of the activity
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.view.View$1.onClick(View.java:3591)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.view.View.performClick(View.java:4084)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.view.View$PerformClick.run(View.java:16966)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.os.Handler.handleCallback(Handler.java:615)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.os.Handler.dispatchMessage(Handler.java:92)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.os.Looper.loop(Looper.java:137)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at java.lang.reflect.Method.invoke(Method.java:511)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at dalvik.system.NativeStart.main(Native Method)
  10-05 10:45:23.730: E/AndroidRuntime(1433): Caused by: java.lang.reflect.InvocationTargetException
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at java.lang.reflect.Method.invoke(Method.java:511)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at android.view.View$1.onClick(View.java:3586)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     ... 11 more
  10-05 10:45:23.730: E/AndroidRuntime(1433): Caused by: java.lang.NullPointerException
  10-05 10:45:23.730: E/AndroidRuntime(1433):     at de.funkypopcorn.reggae_a_gwaan.MainActivity.onClick(MainActivity.java:65)
  10-05 10:45:23.730: E/AndroidRuntime(1433):     ... 14 more
  </code></pre>
  
  <p>Yes, I've searched all different kind of postings and didn't find any solution for my problem.
  (including this one: <a href="https://stackoverflow.com/questions/7083680/how-to-use-asynctask-for-jsoup-parser">How to use AsyncTask for Jsoup Parser?</a>)</p>
  
  <ul>
  <li>Yes I have Internet permission in my Manifest.xml (WebView works great)</li>
  <li>I changed the proxy settings to no-proxy (even though I don't believe it's caused by that, because before the WebView was working as well).</li>
  <li>I tried with different pages and even with plain Ip (so no prob of the DNS)</li>
  </ul>
  
  <p>Maybe there is something obvious misssing? Help really appreciated, thx in advance!</p>
  
  <p>Edit1: According to wireshark the request is send and the answer is given back:
  <img src="https://i.stack.imgur.com/Ws5NU.png" alt="wireshark-cap"></p>
  
  <p>Edit2: It is really strange, sometimes it works and I get an answer. But 3min later when I try it again it does not work anymore. The problem is that it only works ~ 1 out of 10 times. Any ideas?</p>