Android http request not working with WiFi but wor

2019-08-08 12:27发布

I'm having trouble getting a response from a http request when the phone is connected via WiFi. When it's using mobile data everything works fine. Here is the code:

doc = Jsoup.connect("https://www.facebook.com/")
      .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
      .referrer("http://www.google.com")
      .get(); 

I get java.net.SocketTimeoutException:Read timed out exception. I have added these permissions in my manifest file:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Why is it working on mobile data and not on WiFi? (The phone has working internet access through WiFi). Thank you!

0条回答
登录 后发表回答