How to solve RequestTooBigException, connection terminated as request was larger than 10485760?
Asked Answered
G

6

13

I'm trying to upload a 6MB file to my JHipster app server. However, I get the following error. Where can I find the related configuration?

io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 10485760
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2332)
at org.xnio.channels.Channels.readBlocking(Channels.java:294)
at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192)
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168)
at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:213)
at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:792)
Gony answered 26/4, 2018 at 15:12 Comment(4)
Which servlet container are you using?Elston
I use Tomcat as the servlet containerGony
Really? JHipster apps use embedded Undertow as your stack shows.Expeller
I'm getting the same error on Wildfly. Does someone know how to solve it?Magnesium
M
19

Spring Boot has the following default properties

spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.

10485760 = 10MB

See the file upload Spring Boot guide :

Margret answered 26/4, 2018 at 15:22 Comment(0)
F
6

For Spring Boot 1.5.13.RELEASE try this properties:

spring.http.multipart.max-request-size=100MB
spring.http.multipart.max-file-size=100MB
Fruity answered 25/6, 2018 at 14:45 Comment(0)
E
2

At container level, there is the property maxPostSize which can be specified directly on the connector.

From docs:

The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

Elston answered 26/4, 2018 at 15:32 Comment(1)
Is it possible to return message to the user?Impossible
B
1

In addition to maslbl4 answer, for those who uses " .yml " configuration file like me, use the following code :

spring:
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB

It worked fine for me .

Benzol answered 2/11, 2020 at 12:49 Comment(0)
A
-1

open standalone-full.xml file and write {max-post-size="50000000"} here i give the file size 50mb. and my project is running sucessfully.

         <server name="default-server">
            <http-listener name="default" max-post-size="50000000" socket-binding="http" redirect-socket="https" enable-http2="true"/>
            <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <http-invoker security-realm="ApplicationRealm"/>
            </host>
        </se
Autosome answered 12/7, 2022 at 7:41 Comment(0)
S
-1

Using Spring Version :2.3.12 You can use the below properties.

spring.servlet.multipart.max-file-size=35MB
spring.servlet.multipart.max-request-size=35MB

Note :http is depricated

Spelldown answered 7/2, 2023 at 10:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.