2012-04-26 20 views
1

對於某些查詢我收到的 10秒等待響應後,這個ServiceException。DocumentList API FullTextQuery ServiceException - 未知錯誤已發生

我也直接HTTP試圖獲取請求和相同的結果。

例:合同%20Colectiv%20de%20Munc%C4%83

1. My code: 

    URL feedUrl = new URL("https://docs.google.com/feeds/default/private/ full/folder%3A" + folderId + "/contents/-/pdf");       
    DocumentQuery query = new DocumentQuery(feedUrl); 
    query.setFullTextQuery(searchText); 
    client.setConnectTimeout(0);// with or without this line I receive the same result (I also put 30000 value - same result) 
    client.setReadTimeout(0);// with or without this line I receive the same result 

    DocumentListFeed feed = client.getFeed(query, DocumentListFeed.class); 


2. This is the stacktrace for the exception that I receive with documentlist api query: 

    com.google.gdata.util.ServiceException: An unknown error has occurred. 
    <errors xmlns='http://schemas.google.com/g/2005'> 
    <error><domain>GData</domain><code>ServiceException</code> 
    <internalReason>An unknown error has occurred</internalReason> 
    </error></errors> 
    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:624) 
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) 
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java: 552) 
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java: 530) 
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) 
    at com.google.gdata.client.Service.getFeed(Service.java:1135) 
    ... 

3. This is the exception I receive with direct http get request: 

    java.io.IOException: Server returned HTTP response code: 500 for URL: https://docs.google.com/feeds/default/private/full/folder%3[my_folder_doc-id]/contents/-/pdf?q="[query_text]"&max-results=25 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java: 1436) 
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java: 379) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java: 318) 
    at GoogleDocsManager.googleSearch(GoogleDocsManager.java:281) 

其他信息:

1. My folder contains almost 300k files. Could this be the problem? 
2. In ~85% of searches I get the correct response() 
3. In browser the same interogation returns "The server encountered an error. Please try again later", but after refresh works fine. 

誰能幫我得到了這個問題的 「解決方法」?或者如何 避免它?

我張貼了這個問題幾個月前就documentlist api group但由於這組是隻讀的,我不能獲得有關這個問題的任何信息。


這是500的響應我直接HTTP請求得到(後〜10秒):

<errors xmlns='http://schemas.google.com/g/2005'> 
    <error> 
     <domain>GData</domain> 
     <code>ServiceException</code> 
     <internalReason>An unknown error has occurred.</internalReason> 
    </error> 
</errors> 

這是代碼:

URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/folder%3A" + folderId + "/contents/-/pdf?max-results=25&q=" + searchText);       

HttpURLConnection copyHttpUrlConn = (HttpURLConnection) feedUrl.openConnection(); 
copyHttpUrlConn.setDoOutput(true); 
copyHttpUrlConn.setRequestMethod("GET");    
copyHttpUrlConn.setRequestProperty("GData-Version", "3.0"); 
copyHttpUrlConn.setRequestProperty("Authorization", "GoogleLogin auth=" + authToken); 
int respCode = copyHttpUrlConn.getResponseCode(); 

System.out.println("Response code: " + respCode); 

InputStreamReader isr = null; 
if(respCode != 200){ 
    isr = new InputStreamReader(copyHttpUrlConn.getErrorStream()); 
} 
else{ 
    isr = new InputStreamReader(copyHttpUrlConn.getInputStream()); 
} 
BufferedReader br = new BufferedReader(isr); 

String line = null; 
while((line = br.readLine()) != null){ 
    System.out.println(line); 
} 

其他最近的查詢與問題:

  1. title:2012-05「exceptii de neconstitut ionalitate刑法」
  2. 「litigii德munca」
  3. 「MOScrăciunSRL」
  4. 「BIL terenuri SA布加勒斯特」
  5. 「ordonanta去普拉塔」
+0

你試過打印出500的迴應,您有一個直接請求得到的身體嗎?這可能會告訴你更多關於這個問題。另外,您在Google文檔中認真擁有300,000個文檔? – 2012-04-27 01:35:50

+0

嗨尼克, 是的,我有30萬〜(96 GB)的文件,其中95%是小PDF文件。這可能是一個問題嗎? (*)我會寫500響應,我的問題的答覆。 – 2012-04-27 09:00:09

回答

0

正如你可以考慮提取的一種解決方法使用任務隊列離線大文檔列表,以及序列化要在數據存儲中顯示的信息。

使用任務隊列會給你自動重試,如果有錯誤,並且最多10分鐘的urlfetch和處理期限的最後期限。

+0

在api中,它不會影響我做了多少次重試,我收到了同樣的500響應。我的問題是我無法獲得結果,並且因爲查詢在10秒後失敗。 – 2012-04-27 13:06:46

+0

哦,我以爲你說這是85%的時間工作。 – proppy 2012-04-27 13:53:40

相關問題