Android http request not working with WiFi but working on mobile data

爱⌒轻易说出口 提交于 2019-12-13 17:40:23

问题


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!

来源:https://stackoverflow.com/questions/49888639/android-http-request-not-working-with-wifi-but-working-on-mobile-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!