athibanraj / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

Exception in thread "main" java.net.SocketException: Connection reset #49

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Testing Document List API failed (getFeed) with following message:

Exception in thread "main" java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream
(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse
(Unknown Source)
    at com.google.gdata.client.http.HttpGDataRequest.execute(Unknown 
Source)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(Unknown 
Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at com.google.gdata.client.GoogleService.getFeed(Unknown Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at com.nec.webqbe.mdr.test.DocumentTest.printEntry
(DocumentTest.java:74)
    at com.nec.webqbe.mdr.test.DocumentTest.showAllDocs
(DocumentTest.java:36)
    at com.nec.webqbe.mdr.test.DocumentTest.main(DocumentTest.java:29)

Here is the source:

import com.google.gdata.data.BaseEntry;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.client.docs.DocsService;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.util.ServiceException;
import com.google.gdata.data.docs.DocumentListEntry;
import com.google.gdata.data.docs.DocumentEntry;
import com.google.gdata.data.docs.DocumentListFeed;
import com.google.gdata.data.spreadsheet.SpreadsheetEntry;
import com.google.gdata.data.spreadsheet.SpreadsheetFeed;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.client.DocumentQuery;
import java.io.File;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.List;

public class DocumentTest {
    static DocsService service = new DocsService("Document List Demo");

    public static void main(String[] args) throws IOException, 
ServiceException {
        service.setUserCredentials(id, password); // not shown 
        URL documentListFeedUrl = new URL
("http://docs.google.com/feeds/documents/private/full");
        showAllDocs(documentListFeedUrl);   
        showAllWords(documentListFeedUrl);
        showAllSpreadsheets(documentListFeedUrl);
        search("test", documentListFeedUrl);
    }

    public static void showAllDocs(URL documentListFeedUrl) throws 
IOException, ServiceException {
        printEntry(documentListFeedUrl);
    }

    public static void showAllWords(URL documentListFeedUrl) throws 
IOException, ServiceException {
        documentListFeedUrl = new URL(documentListFeedUrl.toString
() + "/-/document");
        printEntry(documentListFeedUrl);
    }

    public static void showAllSpreadsheets(URL documentListFeedUrl) 
throws IOException, ServiceException {
        documentListFeedUrl = new URL(documentListFeedUrl.toString
() + "/-/spreadsheet");
        DocumentListFeed feed = service.getFeed
(documentListFeedUrl, DocumentListFeed.class);
        for (DocumentListEntry entry : feed.getEntries()) {
            printDocumentEntry(entry);
        }
    }

    public static void search(String fullTextSearchString, URL 
documentListFeedUrl) throws IOException, ServiceException {
        DocumentQuery query = new DocumentQuery
(documentListFeedUrl);
        query.setFullTextQuery(fullTextSearchString);
        DocumentListFeed feed = service.query(query, 
DocumentListFeed.class);
        System.out.println("Results for  + fullTextSearchString 
+ ");
        for (DocumentListEntry entry : feed.getEntries()) {
            printDocumentEntry(entry);
        }
    }

    public void uploadFile(String filePath, URL documentListFeedUrl) 
throws IOException, ServiceException {
        DocumentEntry newDocument = new DocumentEntry();
        File documentFile = new File(filePath);
        newDocument.setFile(documentFile);
        // Set the title for the new document. For this example we 
just use the
        // filename of the uploaded file.
        newDocument.setTitle(new PlainTextConstruct
(documentFile.getName()));
        DocumentListEntry uploaded = service.insert
(documentListFeedUrl, newDocument);
        printDocumentEntry(uploaded);
    }

    public static void printEntry(URL documentListFeedUrl) throws 
IOException, ServiceException{
        DocumentListFeed feed = service.getFeed
(documentListFeedUrl, DocumentListFeed.class); // failing statement!!!
        for (DocumentListEntry entry : feed.getEntries()) {
            printDocumentEntry(entry);
        }
    }

    public static void printDocumentEntry(DocumentListEntry doc) {
        String shortId = doc.getId().substring(doc.getId
().lastIndexOf('/') + 1);
        System.out.println(" -- Document(" + shortId + "/" + 
doc.getTitle().getPlainText() + ")");
    }   
}

Your advise is appreciated!
PS. Other API like Calendar or Spreadsheet works fine.

Original issue reported on code.google.com by ytp...@gmail.com on 17 Apr 2008 at 9:58

GoogleCodeExporter commented 9 years ago
Can this be because of chatty network? Were you able to reproduce the issue 
consistently?

I did a quick check, it works fine on our end.  Please let us know if this issue
persists, I can take a closer look at it.

Original comment by vbarat...@gmail.com on 18 Apr 2008 at 12:43

GoogleCodeExporter commented 9 years ago
Ping!  were you able to reproduce the issue.

Original comment by vbarat...@gmail.com on 25 Apr 2008 at 8:06

GoogleCodeExporter commented 9 years ago
Hi,
Thanks for your attention. This problem occurs every time I run the program. 
From the
same machine/network, I can run Calendar and Spreadsheet API properly, but not
DocumentList. 
Regards!

Original comment by ytp...@gmail.com on 30 Apr 2008 at 3:46

GoogleCodeExporter commented 9 years ago
The defect also exist in Google Bloger API. Please fix it.

java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream
(HttpURLConnection.java:1000)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(Unknown 
Source)
    at com.google.gdata.client.http.HttpGDataRequest.execute(Unknown Source)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(Unknown Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at com.google.gdata.client.GoogleService.getFeed(Unknown Source)
    at com.google.gdata.client.Service.getFeed(Unknown Source)
    at Blogger.getBlogId(Blogger.java:80)
    at Blogger.run(Blogger.java:378)
    at Blogger.main(Blogger.java:464)

Original comment by tangqiao...@gmail.com on 16 Jun 2008 at 6:52

GoogleCodeExporter commented 9 years ago
Hi,
   Unfortunately we are not able reproduce the issue with our library on top of
standard jdk5 stack.  Are you still seeing this issue?  If so could you send us 
a
http trace for the conversation?

Cheers.

Original comment by vbarat...@gmail.com on 9 Mar 2009 at 5:25

GoogleCodeExporter commented 9 years ago
error occur when upload a file :

Command: upload c:\aaa.txt aaa
Exception in thread "main" java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.jav
a:535)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:515)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:515)
    at com.google.gdata.client.media.MediaService.insert(MediaService.java:390)
    at sample.docs.DocumentList.uploadFile(DocumentList.java:484)
    at sample.docs.DocumentListDemo.executeUpload(DocumentListDemo.java:613)
    at sample.docs.DocumentListDemo.executeCommand(DocumentListDemo.java:745)
    at sample.docs.DocumentListDemo.run(DocumentListDemo.java:776)
    at sample.docs.DocumentListDemo.main(DocumentListDemo.java:861)

Original comment by yangtong...@gmail.com on 8 Nov 2009 at 7:03

GoogleCodeExporter commented 9 years ago
I use jre1.7.0

Original comment by yangtong...@gmail.com on 8 Nov 2009 at 7:07

GoogleCodeExporter commented 9 years ago
I tried servel times . at first , get list is all right . after i tried servel 
times,
 get list return a fail .

Exception in thread "main" java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.jav
a:535)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:515)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:515)
    at com.google.gdata.client.Service.getFeed(Service.java:1053)
    at com.google.gdata.client.Service.getFeed(Service.java:916)
    at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631)
    at com.google.gdata.client.Service.getFeed(Service.java:935)
    at sample.docs.DocumentList.getDocsListFeed(DocumentList.java:300)
    at sample.docs.DocumentListDemo.executeList(DocumentListDemo.java:392)
    at sample.docs.DocumentListDemo.executeCommand(DocumentListDemo.java:733)
    at sample.docs.DocumentListDemo.run(DocumentListDemo.java:776)
    at sample.docs.DocumentListDemo.main(DocumentListDemo.java:861)

Original comment by yangtong...@gmail.com on 8 Nov 2009 at 7:12

GoogleCodeExporter commented 9 years ago
hi! new to gdata...just trying to use gdata finance api...using jre1.6...just 
wanna
to test getting only few bit of data from finance webservice....got same error:
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
    at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.jav
a:1000)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
    at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.jav
a:535)
.....
could neone plz help me out??

Original comment by sudiproy...@gmail.com on 23 Dec 2009 at 12:48

GoogleCodeExporter commented 9 years ago
Just to PING - hi, neone helping me out for "connection reset" problem???

Original comment by sudiproy...@gmail.com on 29 Dec 2009 at 2:26

GoogleCodeExporter commented 9 years ago
Since you mentioned you were able to get the list sometimes, but fails on other 
attempts, sounds like a network issue (not library issue).  Please check your 
network 
connection to make sure its stable.

Few checks you can do: ping and use curl to retrieve the raw feed.

Original comment by vbarat...@gmail.com on 29 Dec 2009 at 3:05

GoogleCodeExporter commented 9 years ago
If you are in China, the reason may be gfw

Original comment by joles...@gmail.com on 10 May 2010 at 2:42