I use the following code to read google sheet ,Recently at certain times of the day, and this operation always timeout and it used to work normally
public List<List<Object>> getSpreadsheetValue(String spreadsheetId, String dataRange) {
List<List<Object>> values = null;
try {
ValueRange response = sheetsService.spreadsheets().values()
.get(spreadsheetId, dataRange)
.execute();
values = response.getValues();
} catch (IOException e) {
log.error("read google sheet failed ,{}", e.getMessage());
throw new RuntimeException(e);
}
return values;
}
error message:
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)
I tried to set the timeout to 5 minutes but it still return timeout. But if I create a new table and copy the data from this table to the new table, it can work normally without timeout. Also, the range of the table I read is very small and there are no formulas. Has anyone encountered the same problem that can help me thanks
But if I create a new table and copy the data from this table to the new table, it can work normally without timeout.So, why not just use a new copy of the spreadsheet? Sometimes too many revisions(edits saved in revision history) may cause issues.