问题原因:URL超长请求,超出解码长度。
进入网关后报错,如下图An HTTP line is larger than 4096 bytes.
io.netty.handler.codec.http.TooLongHttpLineException: An HTTP line is larger than 4096 bytes.
at io.netty.handler.codec.http.HttpObjectDecoder$LineParser.newException(HttpObjectDecoder.java:1016)
at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.increaseCount(HttpObjectDecoder.java:979)
at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.process(HttpObjectDecoder.java:967)
at io.netty.handler.codec.http.HttpObjectDecoder$LineParser.process(HttpObjectDecoder.java:1011)
具体报错位置,是否报错由maxLength来决定的,maxLength初始化值4096
解决方案:
我们可以在外部设置maxInitialLineLength的长度来改变这个值
在项目application.yml页面添加netty的,不要加成httpclient的
server:
netty:
max-initial-line-length: 100000
另:nginx拦截413情况处理方式
需要修改配置nginx.conf
请求body超过默认大小,需要根据你请求体的大小设置client_max_body_size
在http:{...}中添加
client_max_body_size 10m;
配置好后重启即可。