sarath
sarath

Reputation: 123

Play 2.6, URI length exceeds the configured limit of 2048 characters

I am trying to migrate a Play 2.5 version to 2.6.2. I keep getting the URI-length exceeds error. Anyone knows how to override this?

I tried below Akka setting but still no luck.

play.server.akka{
http.server.parsing.max-uri-length = infinite
http.client.parsing.max-uri-length = infinite      
http.host-connection-pool.client.parsing.max-uri-length = infinite      
http.max-uri-length = infinite
max-uri-length = infinite
}

Upvotes: 4

Views: 8268

Answers (4)

mykey
mykey

Reputation: 2273

If anyone getting this type of error in chrome browser when trying to access a site or login. [HTTP header value exceeds the configured limit of 8192 characters] , Go to chrome

settings -> Security and Privacy -> Site Settings , View Permission and data stored across sites

Search for the specific website and on that site do Clear all data.

Upvotes: 0

Julian Pieles
Julian Pieles

Reputation: 4016

This took me way to long to figure out. It is somehow NOT to be found in the documentation.

Here is a snippet (confirmed working with play 2.8) to put in your application.conf which is also configurable via an environment variable and works for BOTH dev and prod mode:

# Dev Mode
play.akka.dev-mode.akka.http.parsing.max-uri-length = 16384
play.akka.dev-mode.akka.http.parsing.max-uri-length = ${?PLAY_MAX_URI_LENGTH}

# Prod Mode
akka.http.parsing.max-uri-length = 16384
akka.http.parsing.max-uri-length = ${?PLAY_MAX_URI_LENGTH}

You can then edit the config or with an already deployed application just set PLAY_MAX_URI_LENGTH and it is dynamically configurable without the need to modify commandline arguments.

env PLAY_MAX_URI_LENGTH=16384 sbt run

Upvotes: 1

Turtle
Turtle

Reputation: 335

I was getting error due to header length exceeding default 8 KB(8192). Added the following to build.sbt and it worked for me :D

javaOptions += "-Dakka.http.parsing.max-header-value-length=16k"

You can try similar for uri length if other options don't work

Upvotes: 4

mana
mana

Reputation: 6547

Simply add

akka.http {
  parsing {
    max-uri-length = 16k
  }
}

to your application.conf. The prefix play.server is only used for a small subset of convenience features for Akka-HTTP integration into the Playframework, e.g. play.server.akka.requestTimeout. Those are documented in the Configuring the Akka HTTP server backend documentation.

Upvotes: 6

Related Questions