Increasing content-length accept limit for Netty/Finatra

1,163 views
Skip to first unread message

sde...@gmail.com

unread,
Sep 11, 2014, 7:55:21 PM9/11/14
to finatr...@googlegroups.com
I have some unfortunate clients that don't do gzip encoding on posts and their requests fail whenever their payload exceeds 5242880 bytes. Full error below

Is there a way to configure Finatra to use a higher limit for underlying HttpChunkAggregator?

thanks,
arne

WARNING: Unhandled exception in connection with /x.x.x.x:x , shutting down connection
org.jboss.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 5242880 bytes.
at org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:169)
at com.twitter.finagle.http.codec.RespondToExpectContinue.messageReceived(RespondToExpectContinue.scala:29)
at org.jboss.netty.handler.codec.http.HttpContentEncoder.messageReceived(HttpContentEncoder.java:69)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:459)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
at org.jboss.netty.handler.codec.http.HttpServerCodec.handleUpstream(HttpServerCodec.java:56)
at com.twitter.finagle.http.SafeHttpServerCodec.handleUpstream(Codec.scala:41)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

sde...@gmail.com

unread,
Sep 11, 2014, 8:48:12 PM9/11/14
to finatr...@googlegroups.com, sde...@gmail.com
Ok, total red herring on size. I'm routinely getting files several MB large, so that error means something else entirely. Seems to be consistent for certain files tho, so any suggestions where to start digging are appreciated

BTW running Finatra_2.10 1.5.4/ Finagle 6.17.0

sde...@gmail.com

unread,
Sep 12, 2014, 1:30:43 AM9/12/14
to finatr...@googlegroups.com, sde...@gmail.com
The failing file is 44MB (45107062 bytes) and it always fails with the above error. The original upload code was in python, but i've also tried curl, with the same results

sde...@gmail.com

unread,
Sep 12, 2014, 2:06:18 AM9/12/14
to finatr...@googlegroups.com, sde...@gmail.com
Solved it. In case someone else runs into this, it was the Finagle default max request size, which is 5MB and can be overridden with "com.twitter.finatra.config.maxRequestSize"

karlos....@shoesize.me

unread,
Jan 5, 2018, 3:17:39 AM1/5/18
to finatra-users
Hi,

I solved this issue using Finatra 2.5.0 by modifying the Server.scala file:

class Server extends HttpServer {
   
...
   
//this line
   
override val defaultMaxRequestSize =  50.megabytes
 
   
override def configureHttp(router: HttpRouter) {
       
...
   
}
}

It can happen that the issue is related to netty-3.
In my case, this manual didn't make any changes in the netty module finatra was using.

I hope its useful!
Reply all
Reply to author
Forward
0 new messages