vaadin / flow-components

Java counterpart of Vaadin Web Components
101 stars 66 forks source link

Upload Component Error #346

Open allenvpn312 opened 4 years ago

allenvpn312 commented 4 years ago

Upload component unable to upload 700KB file via HTTPS sessions, error states "Server Unavailable". May have to refresh several times before upload works.

Seems to work better with HTTP sessions.

tomcat error [Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.impl.IOFileUploadException: Processing of multipart/form-data request failed. java.io.IOException: Stream reset]

code upload = new Upload(memoryBuffer = new MemoryBuffer()); // 11MB max file upload.setMaxFileSize(11534336); upload.setMaxFiles(1);

Spring boot configuration spring.servlet.multipart.location=/tmp spring.servlet.multipart.enabled=true spring.servlet.multipart.max-file-size=5MB spring.servlet.multipart.max-request-size=5MB

Expecting to upload files greater than 2MB.

- Vaadin / Flow version: 14.4.1
- Java version: OpenJDK 11
- OS version: Debian 10
- Browser version (if applicable): Chrome
- Application Server (if applicable): Tomcat 9
- IDE (if applicable): Eclipse
allenvpn312 commented 4 years ago

Here's an image of the error.

error

tulioag commented 3 years ago

I was not able to get the exact same error.

I was able to reproduce a similar issue in the following way:

The exception is

web_1  | Caused by: org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (5701766) exceeds the configured maximum (5242880)
web_1  |    at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.init(FileItemIteratorImpl.java:146) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.getMultiPartStream(FileItemIteratorImpl.java:190) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.findNextItem(FileItemIteratorImpl.java:209) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.<init>(FileItemIteratorImpl.java:127) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:256) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:280) ~[tomcat-coyote.jar:9.0.40]
web_1  |    at org.apache.catalina.connector.Request.parseParts(Request.java:2869) ~[catalina.jar:9.0.40]
web_1  |    ... 53 common frames omitted
tulioag commented 3 years ago

Should be fixed by vaadin/flow#9492

bostory28 commented 3 years ago

I have same issue for uploading a file. It worked well in Windows even over 200MB file but it doesn't work in Linux. I've got same tomcat error. My tomcat version is 9.0.38.

allenvpn312 commented 3 years ago

If you are running spring boot, try adding these properties to your application.properties file.

server.tomcat.max-swallow-size=-1 server.tomcat.max-http-form-post-size=2MB

Spring file upload

spring.servlet.multipart.enabled=true spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB

bostory28 commented 3 years ago

I have tried to set these configuration but same error. It is going to error page straight away once I click the button without any delay for uploading. I think that the web service seems to be interpreted from Linux during uploading large file. Do you have any idea?

allenvpn312 commented 3 years ago

Are you running tomcat? If so, it is tomcat that is the issue. Look at tomcat's server.xml configuration file. Add something like this.

<Connector port="80" maxSwallowSize="-1" redirectPort="443" enableLookups="false" acceptCount="100" maxThreads="150" disableUploadTimeout="true" connectionTimeout="200000" protocol="HTTP/1.1"/>

The most important property is the maxSwallowSize="-1".

On Thu, Feb 25, 2021 at 4:16 PM bostory28 notifications@github.com wrote:

I have tried to set these configuration but same error. It is going to error page straight away once I click the button without any delay for uploading. I think that the web service seems to be interpreted from Linux during uploading large file. Do you have any idea?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vaadin/vaadin-flow-components/issues/346#issuecomment-786264594, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACIXSWKNCNMJDMUIFRBEH4LTA3D4VANCNFSM4TE35OSQ .

-- Regards, Allen

bostory28 commented 3 years ago

Thank you for the reply. I think that setting maxSwallowSize in server.xml is the same effect with setting "server.tomcat.max-swallow-size" in application.properties. I have tested with setting in application.properties but still not working. As I said before, the weird thing is that this uploading service is working in Windows but not working in Linux. In Linux, uploading process starts failure from around 500KB file size.

allenvpn312 commented 3 years ago

I just upgraded my environment to Ubuntu/Tomcat 9/Java 11 and started getting the upload error. Previously, I was on Debian/Tomcat 8/Java 8 and I was able to upload files in the MB sizes. I might have to revert to Tomcat 8 and Java 8 in the meantime.

allenvpn312 commented 3 years ago

Reverted back to Tomcat 8 and OpenJDK 8 and having no issue with the upload file size. There's a possibility Tomcat 9 is the problem here as I notice some strange behavior when I upgraded to Tomcat 9.

ccarapezza commented 3 years ago

Tomcat version 9.0.3x has another bug for file upload having same infrastructure as the author of this topic. stacktrace below.

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.impl.IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly

I solved it by manually updating Tomcat to version 9.0.43.

credits: https://bugs.launchpad.net/ubuntu/+source/tomcat9/+bug/1903851