0

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

10
  • How heavy is the spreadsheet? Commented Nov 26, 2024 at 10:30
  • About 200 rows and 20 columns, but I only read one row, and each cell has only one number Commented Nov 26, 2024 at 10:41
  • How many sheets/tabs in spreadsheet file? Commented Nov 26, 2024 at 10:41
  • 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. Commented Nov 26, 2024 at 10:44
  • 1
    Not sure... If you're only "read"ing, but not "writing" to the spreadsheet, I don't think it should matter... So, I'm not sure what issue is with your spreadsheet. In any case, see developers.google.com/sheets/api/troubleshoot-api-errors#sheet You can create a issue in the tracker, if the above troubleshooting tips didn't help: developers.google.com/sheets/api/… PS: Make sure your internet connection or ISP is not the cause. Try changing to a different ISP Commented Nov 26, 2024 at 11:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.