Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

413 Request Entity Too Large error is masked by connection error #317

Closed
@falmanna

Description

@falmanna

Please include the following information in your ticket.

  • CloudantClient (java-cloudant) version(s) that are affected by this issue.
    my dependencies:
<dependency>
	<groupId>com.cloudant</groupId>
	<artifactId>cloudant-client</artifactId>
	<version>2.6.2</version>
</dependency>
<dependency>
	<groupId>com.squareup.okhttp3</groupId>
	<artifactId>okhttp-urlconnection</artifactId>
	<version>3.4.2</version>
</dependency>
<dependency>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
          <version>2.5</version>
</dependency>

  • Java version (including vendor and platform).
    Windows 10
    Java 8
    JavaSE 1.8 - jdk 1.8.0_112

  • If you're using the optional okhttp dependency.
    yes I am using

  • A small code sample that demonstrates the issue.

Database db = cloudant.database(dbName, true);
List<Response> responses = db.bulk(topics); //Error happening here

here is the ERROR LOG

com.cloudant.client.org.lightcouch.CouchDbException: Error retrieving server response
	at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:558) ~[cloudant-client-2.6.2.jar:na]
	at com.cloudant.client.org.lightcouch.CouchDatabaseBase.bulk(CouchDatabaseBase.java:284) ~[cloudant-client-2.6.2.jar:na]
	at com.cloudant.client.api.Database.bulk(Database.java:935) ~[cloudant-client-2.6.2.jar:na]
	at storage.CloudantStorage.insertTopicList(CloudantStorage.java:40) ~[classes/:na]
	at main.MainTaskStream.run(MainTaskStream.java:122) ~[classes/:na]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_112]
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_112]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.8.0_112]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_112]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_112]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_112]
	at java.lang.Thread.run(Unknown Source) [na:1.8.0_112]
Caused by: java.io.IOException: Error writing request body to server
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(Unknown Source) ~[na:1.8.0_112]
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(Unknown Source) ~[na:1.8.0_112]
	**at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2147) ~[commons-io-2.5.jar:2.5]
	at com.cloudant.http.HttpConnection.execute(HttpConnection.java:336) ~[cloudant-http-2.6.2.jar:na]
	at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:481) ~[cloudant-client-2.6.2.jar:na]**
	... 11 common frames omitted

I traced the code to find the error, it leads me to this code from inside the library

public static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer)
            throws IOException {
        long count = 0;
        int n;
        while (EOF != (n = input.read(buffer))) {
            output.write(buffer, 0, n); //ERROR happened here, looks like it is happening because of closed OutputStream as noted from write() method description, but I couldn't find why?  
            count += n;
        }
        return count;
    }

NOTES:

  • I am able to read docs from this database and write single documents, but failing to bulk insert.
  • The inserted List size is less than 300KB.
  • The code is running with a local instant of CouchDB without any errors.

thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions