4

For our application we are using Google Drive SDK with 2-legged authorization. We are using Drive SDK for a long time, but today we faced with new issue for Files.list API (https://developers.google.com/drive/v2/reference/files/list). For some users, from different domains we got following error:

{ "error": { "code": 500, "message": null } }

Is everything OK with Drive SDK? What does this error mean?

Abliamit
  • 483
  • 1
  • 3
  • 13

1 Answers1

1

I recommend read this post that helped me to configure and connect to Google Drive with Android

EDIT:

I had the same 500 error server, to avoid this error Google recommend the Exponential backoff that according to them:

Exponential backoff is a standard error handling strategy for network applications in which the client periodically retries a failed request over an increasing amount of time. If a high volume of requests or heavy network traffic causes the server to return errors, exponential backoff may be a good strategy for handling those errors. Conversely, it is not a relevant strategy for dealing with errors unrelated to rate-limiting, network volume or response times, such as invalid authorization credentials or file not found errors.

Used properly, exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments.

Example:

Android code:

FileList files = null;

for (int n = 0; n < 5; ++n) {

   try {
      setStatus("trying n = " + n);
      files = service.files()
        .list()
        .setMaxResults(1)
        .setQ("mimeType = 'application/vnd.google-apps.folder' and title = 'folder_title'")
        .execute();
   }
   catch (GoogleJsonResponseException e)
   {
      if (e.getDetails().getCode() == 500) {
        try {
            Thread.sleep((1 << n) * 1000 + randomGenerator.nextInt(1001));
            setStatus("sleep() n = " + n);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            setStatus("InterruptedException n = " + n + " " + e1.getMessage());
            e1.printStackTrace();
        }
      }
   }

}

I have tested this code and in the last try it connects successfully

Google recommend to use the Exponential backoff with 4xx and 5xx server error

The 4xx server errors are mostly for authentication problem

Community
  • 1
  • 1
tttony
  • 4,944
  • 4
  • 26
  • 41