简体   繁体   中英

Play 2.6 EntityStreamSizeException exception

In my application I need to upload quite large files (up to 4GB). I do it using file form field and save the file to temporary location for further processing. However when it comes to files that exceed the content-size limit I get an EntityStreamException:

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[EntityStreamSizeException: EntityStreamSizeException: actual entity size (Some(781434380)) exceeded content length limit (8388608 bytes)! You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` before materializing the dataBytes stream.]]

I've tried to set both akka.*.[client|server] limits in my application.conf as follows:

akka.http.server.parsing.max-content-length = 4096MB
akka.http.client.parsing.max-content-length = 4096MB

but it still crashes with the same message. I've also tried to follow the documentation and set play's settings:

play.http.parser.maxMemoryBuffer=512k
play.http.parser.maxDiskBuffer=4096MB 

as it is proposed here: https://www.playframework.com/documentation/2.6.x/ScalaBodyParsers

The last thing I've tried was to explicitly override the setting in my post handler:

def doCreate = checkToken {
    Action(parse.maxLength(400000000, parse.multipartFormData)) { implicit request =>
    ...
}

Nothing seems to work. Can anybody tell me what I'm doing wrong?

Upd: After lurking in play/akka code and some debugging I can see that any akka related settings just being completely ignored. I see that play.http.parser setting is propagated to context and is used, however any akka setting is not applied and maxContentLength remains set to default value of 8MB. But according to this document: https://www.playframework.com/documentation/2.6.x/SettingsAkkaHttp they should be applied. Not sure what to do next. Any help will be really appreciated.

I've found a related pull request: https://github.com/playframework/playframework/pull/7548

So, as I understand, this setting should not work. The message in the exception is misleading.

UPD : https://blog.playframework.com/play-2-6-1-released/ here in change notes this merge request is present. After updating to Play 2.6.1 I can see that akka max-content-limit is set to infinite so only play settings counts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM