Google Drive Files.list:500错误 [英] Google Drive Files.list: 500 error

查看:247
本文介绍了Google Drive Files.list:500错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的应用程序,我们使用Google Drive SDK进行双腿授权。
我们长期使用Drive SDK,但今天我们面临Files.list API的新问题( https://developers.google.com/drive/v2/reference/files/list )。对于某些用户,来自不同的域名,我们有以下错误:


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


Drive Drive SDK一切正常吗?这个错误是什么意思?

解决方案

我推荐阅读文章帮助我使用Android配置和连接到Google Drive

编辑



我使用了相同的500错误服务器,为避免此错误,Google建议使用 指数回退 根据它们:


指数回退是网络
应用程序的一种标准错误处理策略,其中客户端定期在不断增加的时间内重试失败请求
。如果大量请求或
大量网络流量导致服务器返回错误,则指数
退避可能是处理这些错误的好策略。相反,
并不是处理与
速率限制,网络数量或响应时间无关的错误的相关策略,例如无效
授权凭证或文件未找到错误。



正确使用时,指数回退会增加
带宽使用的效率,减少获得
成功响应所需的请求数,并最大化请求的吞吐量在
并发环境中。

示例:



Android代码:

  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自动生成的catch块
setStatus(InterruptedException n =+ n ++ e1.getMessage());
e1.printStackTrace();
}
}
}

}

我测试了这段代码,并在最后一次尝试中成功连接了

Google建议使用4xx和5xx服务器的指数回退错误



4xx服务器错误主要用于身份验证问题


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?

解决方案

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

这篇关于Google Drive Files.list:500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆