所有使用 Volley 的请求都会出现 TimeoutError
我正在尝试提出一些基本要求。然而,每个请求都会返回超时错误。我尝试了许多不同的网址。我的设备已连接到互联网。我通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您添加
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.