TooLongHttpLineException: An HTTP line is larger than XXX bytes.
search cancel

TooLongHttpLineException: An HTTP line is larger than XXX bytes.

book

Article ID: 297148

calendar_today

Updated On:

Products

Support Only for Spring

Issue/Introduction

When requests are passed through Spring Cloud Gateway the request errors out with an exception below
 

io.netty.handler.codec.http.TooLongHttpLineException: An HTTP line is larger than 4096 bytes.





Environment

Product Version: 1.0+

Resolution

The issue is caused by a request with having a long query string exceeding Netty's max-initial-line-length configuration. Default value can be found here 

First check how big is your query string then change Netty's max-initial-line-length  configuration accordingly

cf update-service <gateway-service-name> -c '{ "env": { "JAVA_OPTS": "-Dserver.netty.max-initial-line-length=32KB"} }'


On a side note, If you don't have a long query string but rather you have large size request header, please change the max-header-size instead:
 

cf update-service SERVICE-NAME -c '{ "max-header-size": "32k" }'