Monday, August 1, 2016

FileUploadException: UT000020: Connection terminated as request was larger than 10485760

In the course of our limits testing, it turns out that it wasn't enough to just set the file upload limit in our own application for the CommonsMultipartResolver, using our spring-*context.xml configuration. WildFly had other ideas of its own. It comes out of the box with the default limit of 10485760 bytes.

While I managed to locate a couple of results such as this, this, this and this, which pointed me in the right direction, they were all referencing older versions, namely WildFly 8. And being lazy that I am, I'm not about to poke around the XML making changes manually, much less use the CLI to amend the value. I wanted to make the change via the WildFly Admin Console UI.

Thus I had to make explorations of my own. Based on those clues, I've identified the whereabouts to change said value.

Navigate to the Configuration tab > Subsystems > Web/HTTP - Undertow > HTTP and click View


HTTP Server tab > "default-server" > View

HTTP Listener > Edit

Then edit the "Max post size" to your desired value. Naturally, I'd think that the value should match whatever you've configured in your own application.

And don't forget to restart your WildFly!

Edit: Also, don't forget to tweak your database e.g. MySQL for the max_allowed_packet alongside this setting!

4 comments:

  1. Many thanks for your tip, it got me in the right path. In case someone is using an Apache server with mod_jk as frontend, you must make the same change in AJP Listener.

    ReplyDelete
    Replies
    1. Oh wow, hi there! I'm glad to have helped, even if it's a teensy bit. I'll be sure to take note of what you mentioned for AJP too. :)

      Delete
  2. Thanks for the information!

    For anyone using Wildfly 16 I had to do something different to increase that parameter:

    ===============================
    To view default wildfly setting
    ===============================
    wf admin console on port 9990
    Under 'Configuration' select 'Subsystems'
    Under 'Subsystem' select 'Web',
    Under 'Settings' select 'Server',
    Under 'Server' select 'default-server'
    Click 'View',
    Click 'Listener',
    Click 'HTTP Listener'

    Server->Default-server,
    Listener>
    Max Post Size

    =========
    To change
    =========
    make sure wildfly server is running
    open command prompt and cd to your wildfly bin folder
    Run 'jboss-cli'
    Enter 'connect'
    Enter:
    /subsystem=undertow/server=default-server/http-listener=default/:write-attribute(name=max-post-size,value=15360000)

    (no spaces in above string)
    (I used 15MB in the example)

    A success response should come back like this:

    {
    "outcome" => "success",
    "response-headers" => {
    "operation-requires-reload" => true,
    "process-state" => "reload-required"
    }
    }

    You will then see the new value stored in standalone.xml

    ReplyDelete
  3. Thanks you very much for the information. It help me lot to resolve issue I faced

    ReplyDelete