2016-03-29 32 views
7

Ben çok parçalı dosyası (boyut 18M) yüklemeye çalışırken, Play Framework 2.4.6 kullanıyorum ve sunucu aşağıdaki hata verir: Etrafa baktıkPlay Framework 2.4.6 hata 413 Talep

For request 'POST /api/myEndpoint' [Request Entity Too Large] 

  1. play.http.parser.maxMemoryBuffer = 2000000K
  2. parsers.MultipartFormData.maxLength = 1024000K
  3. play.http.parser.maxDiskBuffer: ve dışarı başarı ile şu çalıştı = 2000000K
  4. Action.async (parse.anyContent (Bazı (1024 * 200L)))

Ve bunların hiçbiri sorunu çözer.

Burada hem StackTrace geçerli:

14:57:33.128 [New I/O worker #2] [error] -  p.c.server.netty.RequestBodyHandler - Exception caught in RequestBodyHandler 
java.nio.channels.ClosedChannelException: null 
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.setInterestOps(AbstractNioWorker.java:506) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.nio.AbstractNioWorker$1.run(AbstractNioWorker.java:455) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.ChannelRunnableWrapper.run(ChannelRunnableWrapper.java:40) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.10.4.Final.jar:na] 
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.10.4.Final.jar:na] 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65] 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65] 
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65] 

cevap

16

bu sorun çözüldü:

play.http.parser.maxDiskBuffer = 100MB 

parsers.anyContent.maxLength = 100MB 
+0

Teşekkürler bu bana yardımcı oldu :) – Seeker

+0

@gleeb uygulamada bu seçenekleri nereye koyabileceğimizi rahatlıkla anlatın ifle? Bu seçenekleri application.conf'un sonuna koydum ama işe yaramıyor. – Tom

+0

application.conf – Gleeb

7
Ben büyük bir form göndererek de aynı sorunu vardı

ve play.http.parser.maxMemoryBuffer=4MB onu çözdüm.

+1

Teşekkürler! Bu benim için hatayı çözdü. – Blackbird

4

bellek ve disk tamponları kullanır Play ile ilgili bu belgelere bakın: https://www.playframework.com/documentation/2.4.x/ScalaBodyParsers#Max-content-length

Yani

Text based body parsers (such as text, json, xml or formUrlEncoded) use a max content length because they have to load all the content into memory. By default, the maximum content length that they will parse is 100KB. It can be overridden by specifying the play.http.parser.maxMemoryBuffer property in application.conf:

play.http.parser.maxMemoryBuffer=128K

For parsers that buffer content on disk, such as the raw parser or multipart/form-data, the maximum content length is specified using the play.http.parser.maxDiskBuffer property, it defaults to 10MB. The multipart/form-data parser also enforces the text max length property for the aggregate of the data fields.

, bir çok parçalı bir dosya yükleyerek çalışıyorsanız beri sen> 18MB şey play.http.parser.maxDiskBuffer artırmanız gerekir .

Yani, dosyasına koyarak bu ekleyerek bunu düzeltmek gerekir: bkz Çal Çerçeve 2.6.x sorunla karşı karşıya olanlar belgeler için

play.http.parser.maxDiskBuffer=100MB 
0

https://www.playframework.com/documentation/2.6.x/ScalaBodyParsers

Max content length Text based body parsers (such as text, json, xml or formUrlEncoded) use a max content length because they have to load all the content into memory. By default, the maximum content length that they will parse is 100KB. It can be overridden by specifying the play.http.parser.maxMemoryBuffer property in application.conf:

eklenti de aşağıdaki application.conf:

play.http.parser.maxMemoryBuffer = 5MB 
+0

Bu cevap, önceki çözümlerle aynı çözümü yinelemektedir. Ekleyecek bir şeyiniz olduğunu düşünüyorsanız, lütfen orijinal yanıtla ilgili yorum olarak bırakın. Alternatif olarak farklı bir çözümünüz varsa, lütfen neden farklı olduğunu (ve muhtemelen daha iyi) açıklayın. – MTCoster