Sometimes when we poll for a BigQuery job, our request ends up with SocketTimeoutException
. You can see the code raising the exception below.
this.bigquery.jobs().get(projectNumber, jobId).execute();
And here is the error message we get.
...
Caused by: java.net.SocketTimeoutException:
Timeout while fetching URL: https://www.googleapis.com/bigquery/v2/projects/######/jobs/######
...
My question is if there is a way to extend the timeout. And does anyone know what the default timeout is?
You can wrap the credential object in a HTTP initializer that disables (or extends) timeouts. That is, where you currently have this:
Credential credential = ...
Bigquery bigquery = new Bigquery(HTTP_TRANSPORT, JSON_FACTORY, credential);
you could do
final Credential credential = ...
HttpRequestInitializer initializer = new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
credential.initialize(request);
request.connectTimeout = request.readTimeout = 0;
}
}
Bigquery bigquery = new Bigquery(HTTP_TRANSPORT, JSON_FACTORY, initializer);
See this for BigQuery object javadoc, this for BigQuery object creation example, and this for HttpRequestInitializer overloading.
If it is the only that you want to set a timeout to then in request body: :
query_config = { 'timeoutMs': 1000,
set timeoutsMs to whatever you like withing reason ;)
Hope that helps the documentation is here
To get the results of the query even if it hasn't obeyed the timeout Call jobs.getQueryResults
taken from the site you must specify a start row, and this also takes a timeout that behaves the same as the jobs.query timeout to allow waiting if the job is not yet complete.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.