для чтения
Код: Выделить всё
public List[*]> getSpreadsheetValue(String spreadsheetId, String dataRange) {
List values = null;
try {
Sheets sheetsService = getRandomService();
ValueRange response = sheetsService.spreadsheets().values()
.get(spreadsheetId, dataRange)
.execute();
values = response.getValues();
} catch (IOException e) {
throw new RuntimeException(e);
}
return values;
}
Код: Выделить всё
public void batchUpdate(String spreadsheetId, String range, List values) {
Sheets sheetsService = getRandomService();
ValueRange requestBody = new ValueRange().setValues(values);
try {
UpdateValuesResponse response = sheetsService.spreadsheets().values()
.update(spreadsheetId, range, requestBody)
.setValueInputOption(ValueInputOption.USER_ENTERED.toString())
.execute();
} catch (IOException e) {
log.error("update google sheet failed ,{}", e.getMessage());
}
}
Код: Выделить всё
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:476)
at sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:470)
at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1369)
at sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:73)
at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:978)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:743)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1600)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1505)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:352)
at com.google.api.client.http.javanet.NetHttpResponse.(NetHttpResponse.java:36)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:149)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
at com.kikatech.earning.utils.GoogleSheetUtils.getSpreadsheetValue(GoogleSheetUtils.java:317)
- Нет формул и импорта внешних данных. Лист содержит менее 500 строк, причем в каждой строке не более 30 столбцов. Ячейки содержат простые числа, и каждая операция считывает или обновляет только самые последние строки.
- Обновления происходят часто, примерно каждые 20 минут.< /p>
- На этот лист ссылаются другие листы.
- Я подтвердил, что на моем сервере нет проблем с сетью. Таймауты возникают в разных серверных средах, в том числе локально.
- Когда я копирую этот лист на новый лист и работаю с новым, возникают проблем с тайм-аутом нет.
- Тайм-аут не связан с объемом считываемых или записываемых данных. Даже чтение одной ячейки приводит к таймауту, когда это происходит.
Подробнее здесь: https://stackoverflow.com/questions/792 ... pi-timeout
Мобильная версия