Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
825 views
in Technique[技术] by (71.8m points)

playframework - One of the example projects listed by Lightbend is not working for larger files

I did post this same question at LightBend's discussion group here, but cannot get an answer that solves my issue. Since I am really anxious to know what is the problem here, let me again post this question here, hoping a big audience group might mean a better chance of getting an answer.

So basically, at this page, https://developer.lightbend.com/start/?group=play, we can find a list of example Play! projects. Among these examples, there is one project is about Java File Upload (https://developer.lightbend.com/start/?group=play&project=play-samples-play-java-fileupload-example). This project teaches the readers how to create a file uploader using Akka Streaming idea, therefore even when the file is large, we can still safely upload it without reading it as a whole into the memory.

This project works for small files, but when I try to upload a larger file, for example, which has a size about 15M, I will get a page says “The connection was reset”.

Now, in this example project, inside application.conf file, I see this,

# **Sets the maximum file size that can be uploaded to 1024k.**
# https://www.playframework.com/documentation/2.8.x/JavaBodyParsers#Content-length-limits
play.http.parser.maxMemoryBuffer=1024k

Indeed - if I upload any file that is smaller than 1024k, it will work, but anything larger than that, it will not work.

Now, I am very confused. Notice 1024k is the size of maxMemoryBuffer! This does not make sense to me because the whole idea of “streaming it”, is to be able to stream it with a much smaller memory buffer and without reading the whole file into the memory first. But the file size has to be smaller than play.http.parser.maxMemoryBuffer??? this makes me think it might just read the whole file into memory …

I know I am wrong, but just don't know where I am wrong and what I have missed. I hope someone with a better idea can see this question and will kindly let me know what is happening… Thank you so much for the help!

UPDATE:

Let me add a little bit more information here. So if I upload a file that is larger than play.http.parser.maxMemoryBuffer, the error message is the following (using Chrome):

This site can’t be reached
ERR_CONNECTION_ABORTED

and here is what I see in the log:

[debug] a.h.i.u.StreamUtils$DelayCancellationStage$$anon$11 - Delaying cancellation for 1 minute

Hope this can be of some help??

question from:https://stackoverflow.com/questions/65854900/one-of-the-example-projects-listed-by-lightbend-is-not-working-for-larger-files

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your application.conf set;

play.http.parser.maxDiskBuffer=500MB

We needed this to allow video uploads to our play app. Default is 10M if you not set one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...