I’m using the GroupDocs Viewer Java SDK to preview documents in our web app. For some documents, I am sometimes (not always) receiving the following error from GroupDocs when I attempt to upload the document:
Jun 25 15:28:50 : com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: Connection reset
Jun 25 15:28:50 : at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:151)
Jun 25 15:28:50 : at com.sun.jersey.api.client.Client.handle(Client.java:648)
Jun 25 15:28:50 : at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
Jun 25 15:28:50 : at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
Jun 25 15:28:50 : at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
Jun 25 15:28:50 : at com.groupdocs.sdk.common.ApiInvoker.invokeAPI(ApiInvoker.java:218)
Jun 25 15:28:50 : at com.groupdocs.sdk.api.StorageApi.Upload(StorageApi.java:196)
This is the code snippet that is creating the error, taken almost exactly from your Java SDK samples:
ApiInvoker.getInstance().setRequestSigner( new GroupDocsRequestSigner( PRIVATE_KEY ));
final StorageApi storageApi = new StorageApi();
storageApi.setBasePath( PREVIEW_URL );
final FileStream fileStream = new FileStream( dataStream );
fileStream.setFileName( encodedFileName );
final UploadResponse uploadResponse = storageApi.Upload( CLIENT_ID, encodedFileName, null, null, fileStream );
I have tested this over and over with the same document. Sometimes it returns successfully and I am able to preview it, and other times I get the above SocketException. It seems to happen for certain documents more than others, but I haven’t yet been able to find a pattern.
When I upload this same document and try to preview it there, sometimes it works and sometimes it doesn’t. Does anyone have any idea what might be causing this? If there was a problem with the document I would assume that it would never work, but this is not the case.