0
我正在处理Volley POST请求,并在单独的线程中运行该文章。我看到的问题是,即使设置了超时值,RequestFuture也会立即超时(小于一秒)。有人可以帮忙吗?服务器URL是可访问的,它返回200 OK,但RequestFuture get不会等待服务器响应。 错误:java.util.concurrent.ExecutionException:com.android.volley.TimeoutError排球网络总是超时
Thread t = new Thread(new Runnable() {
@Override
public void run() {
RequestFuture<JSONObject> future = RequestFuture.newFuture();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, jsonBody, future, future);
RequestQueue queue = Volley.newRequestQueue(context);
queue.add(request);
try {
JSONObject response = future.get(50, TimeUnit.SECONDS);
if(response != null) {
DialogUtility.alert(context, response.toString());
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
}
});
t.start();