fsi
fsi

Reputation: 1367

Jetty too much data after closed for HttpChannelOverHttp

I'm having trouble with upload one audio file >10s and gives me this error:

WARN:oejh.HttpParser:qtp1359061041-19: badMessage: java.lang.IllegalStateException: too much data after closed for HttpChannelOverHttp@7fd0cbe{r=5,a=IDLE,uri=-}

If I upload audio file <10s it goes ok.

I searched on google, but I couldn't find any solution for this. There's any solution for this?

Upvotes: 8

Views: 10045

Answers (6)

Pieter van Ginkel
Pieter van Ginkel

Reputation: 29632

For me the problem was that I wasn't reading from the input. The error wasn't triggered every time, but when the input became beyond a certain size, these errors would occur. Simple fully reading the input stream before writing to the output stream solved the issue for me.

Upvotes: 0

David Carboni
David Carboni

Reputation: 2156

For Googlers, I ran into this issue and fixed it by changing parameter annotations from @FormParam to @FormDataParam:

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response post(
        @FormParam("name") String name,
        @FormParam("file") InputStream file) {
    //...
}

to:

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response post(
        @FormDataParam("name") String name,
        @FormDataParam("file") InputStream file) {
    //...
}

I'm running on Heroku and, having found the solution by chance, have found the following documentation:

Which says:

This annotation in conjunction with the media type "multipart/form-data" should be used for submitting and consuming forms that contain files, non-ASCII data, and binary data.

Upvotes: 0

Luca Fagioli
Luca Fagioli

Reputation: 13359

In my case, the client was sending more form keys than the amount that the server was allowed to receive.

So I had to set

WebAppContext webapp = new WebAppContext();
webapp.getServletContext().getContextHandler().setMaxFormKeys(1000000000);

in the jetty server side.

Upvotes: 0

fsi
fsi

Reputation: 1367

I'm using Cordova 3.3.0, and the problem was on the upload. The code below solved my case:

var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=name;
    options.mimeType = "audio/amr";
    options.headers = {
        Connection: "close"
    }
    options.chunkedMode = false;

From why jetty keep giving me the too much data after closed(Will try my best to explain). The connection must be closed after do another connection and request. For example, my upload keep reusing the same request and overflow the request and give me the message. So basically, for each request, must close and open new one.

For precaution, I made changes on jetty.xml

<Set name="outputBufferSize"><Property name="jetty.output.buffer.size" default="65536" /></Set>
<Set name="requestHeaderSize"><Property name="jetty.request.header.size" default="16384" /></Set>
<Set name="responseHeaderSize"><Property name="jetty.response.header.size" default="16384" /></Set>

Upvotes: 1

Dinesh
Dinesh

Reputation: 31

To run the server from init.d, copy the script ${JETTY_HOME}/bin/jetty.sh to /etc/init.d/ folder (If you want to start jetty during system boot). Make sure the script has execute permissions. Run the script like

sudo /etc/init.d/jetty start (I have copied jetty.sh as jetty in /etc/init.d/ folder)

Upvotes: 0

Virmundi
Virmundi

Reputation: 2631

This sounds like a similar issue that's discussed here http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03919.html

How are you starting Jetty? Is it from the command line where log information goes to STOUT? If so, you might need to start the app as a service or configure the log level lower.

Upvotes: 0

Related Questions