所有使用 Volley 的请求都会出现 TimeoutError

发布于 2025-01-11 22:51:09 字数 1999 浏览 0 评论 0原文

我正在尝试提出一些基本要求。然而,每个请求都会返回超时错误。我尝试了许多不同的网址。我的设备已连接到互联网。我通过 Android Studio 中的 WiFi 配对进行连接。我已授予我的应用 INTERNET 权限。我已经尝试将超时设置为 30 秒,但仍然发生:

val queue = Volley.newRequestQueue(this)
val basicRequest = StringRequest(Request.Method.GET, "https://google.com", 
    {Log.w("APP", "SUCCESS")},
    {Log.e("APP", it.stackTraceToString())})
queue.add(basicRequest)
2022-03-04 21:09:20.173 2924-2966/com.myapp D/Volley: [286] WaitingRequestManager.maybeAddToWaitingRequests: new request, sending to network 1-https://google.com
2022-03-04 21:09:21.211 2924-2924/com.myapp E/APP: com.android.volley.TimeoutError
        at com.android.volley.toolbox.NetworkUtility.shouldRetryException(NetworkUtility.java:162)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:145)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
2022-03-04 21:09:21.212 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (1043 ms) [ ] https://google.com 0xa46e044c NORMAL 2
2022-03-04 21:09:21.213 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [ 2] add-to-queue
2022-03-04 21:09:21.213 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+2   ) [286] cache-queue-take
2022-03-04 21:09:21.214 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [286] cache-miss
2022-03-04 21:09:21.215 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+3   ) [290] network-queue-take
2022-03-04 21:09:51.216 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+1035) [290] socket-timeout-giveup [timeout=30000]
2022-03-04 21:09:51.217 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [290] post-error
2022-03-04 21:09:51.217 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+3   ) [ 2] done

发生了什么事?

I am trying to make some basic requests. However every request is returning a Timeout error. I have tried a number of different urls. My device is connected to the internet. I am connected via a WiFi pairing in Android Studio. I have given my app the INTERNET permission. I have tried overriding the timeout to 30s and it still happens:

val queue = Volley.newRequestQueue(this)
val basicRequest = StringRequest(Request.Method.GET, "https://google.com", 
    {Log.w("APP", "SUCCESS")},
    {Log.e("APP", it.stackTraceToString())})
queue.add(basicRequest)
2022-03-04 21:09:20.173 2924-2966/com.myapp D/Volley: [286] WaitingRequestManager.maybeAddToWaitingRequests: new request, sending to network 1-https://google.com
2022-03-04 21:09:21.211 2924-2924/com.myapp E/APP: com.android.volley.TimeoutError
        at com.android.volley.toolbox.NetworkUtility.shouldRetryException(NetworkUtility.java:162)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:145)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
2022-03-04 21:09:21.212 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (1043 ms) [ ] https://google.com 0xa46e044c NORMAL 2
2022-03-04 21:09:21.213 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [ 2] add-to-queue
2022-03-04 21:09:21.213 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+2   ) [286] cache-queue-take
2022-03-04 21:09:21.214 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [286] cache-miss
2022-03-04 21:09:21.215 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+3   ) [290] network-queue-take
2022-03-04 21:09:51.216 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+1035) [290] socket-timeout-giveup [timeout=30000]
2022-03-04 21:09:51.217 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+0   ) [290] post-error
2022-03-04 21:09:51.217 2924-2924/com.myapp D/Volley: [2] MarkerLog.finish: (+3   ) [ 2] done

What is going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2025-01-18 22:51:09

当您添加INTERNET权限时,您需要从设备上完全卸载该应用程序。执行此操作并重新加载后,它连接正常。

When you add the INTERNET permission, you need to completely uninstall the app from your device. After doing this and reloading it, it connects fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文