Jetty too much data after closed for HttpChannelOverHttp

↘锁芯ラ 提交于 2019-12-18 07:45:07

问题


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?


回答1:


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>



回答2:


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.




回答3:


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)




回答4:


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.




回答5:


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:

  • https://jersey.java.net/nonav/apidocs/1.0.3/contribs/jersey-multipart/com/sun/jersey/multipart/FormDataParam.html

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.




回答6:


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.



来源:https://stackoverflow.com/questions/22510218/jetty-too-much-data-after-closed-for-httpchanneloverhttp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!