Finatra TooLongMessageException HTTP content length exceeded 5242880 bytes, despite flag setting more bytes

804 views Asked by At

I'm seeing a TooLongMessageException HTTP content length exceeded 5242880 bytes. exception thrown from my finatra server. Looking at the flags available via -help=true, it looks like the flag to set is maxRequestSize. Here is the output of the help command

flags:
  -admin.announce='java.lang.String': Address for announcing admin server
  -admin.port=':9990': Admin http server port
  -cert.path='': path to SSL certificate
  -doc.root='': File serving directory/namespace for classpath resources
  -help='false': Show this help
  -http.announce='java.lang.String': Address for announcing HTTP server
  -http.name='http': Http server name
  -http.port=':8080': External HTTP server port
  -http.response.charset.enabled='true': Return HTTP Response Content-Type UTF-8 Charset
  -https.announce='java.lang.String': Address for announcing HTTPS server
  -https.name='https': Https server name
  -https.port='': HTTPs Port
  -key.path='': path to SSL key
  -local.doc.root='': File serving directory for local development
  -log.append='true': If true, appends to existing logfile. Otherwise, file is truncated.
  -log.async='true': Log asynchronously
  -log.async.inferClassNames='false': Infer class and method names synchronously. See com.twitter.logging.QueueingHandler
  -log.async.maxsize='4096': Max queue size for async logging
  -log.level='INFO': Log level
  -log.output='/dev/stderr': Output file
  -log.rollPolicy='Never': When or how frequently to roll the logfile. See com.twitter.logging.Policy#parse documentation for DSL details.
  -log.rotateCount='-1': How many rotated logfiles to keep around
  -maxRequestSize='5242880.bytes': HTTP(s) Max Request Size
  -mustache.templates.dir='templates': templates resource directory
  -shutdown.time='1.minutes': Maximum amount of time to wait for pending requests to complete on shutdown
  -thrift.announce='java.lang.String': Address for announcing Thrift server
  -thrift.name='thrift': Thrift server name
  -thrift.port=':9999': External Thrift server port
  -thrift.shutdown.time='1.minutes': Maximum amount of time to wait for pending requests to complete on shutdown

I've passed in -maxRequestSize=10.megabytes and can see the value in the /admin/registry.json document: maxRequestSize: "10485760.bytes" but I'm still seeing the TooLongMessageException with the 5 megabyte value. How do I increase this max size?

1

There are 1 answers

0
AudioBubble On

Maybe in code it is being overwritten?

You could do it programmatically

> override def configureHttpServer(server: Http.Server): Http.Server = {
>     server.withAdmissionControl.concurrencyLimit(maxConcurrentRequests = 2000, maxWaiters = 0)
>       .withResponseClassifier(HttpResponseClassifier.ServerErrorsAsFailures)
>       .withMaxRequestSize(StorageUnit.fromMegabytes(200))
>       .withRequestTimeout(50.seconds)   }