欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

springboot报错 [io-29001-exec-8] o.apache.coyote.http11.Http11Processor

程序员文章站 2024-02-14 17:23:28
...
  1. springboot 项目运行一段时间报错
2019-12-08 17:11:37.116  INFO 16380 --- [io-29001-exec-8] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
 at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:415) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) [tomcat-embed-core-9.0.21

解决方法

  1. Tomcat的header缓冲区大小不够,只需要在server.xml中增加maxHttpHeaderSize字段即可:
<Connector URIEncoding="UTF-8" port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
useBodyEncodingForURI="false"
enableLookups="false"
               connectionTimeout="20000"

               redirectPort="8443" maxHttpHeaderSize="你想要的大小"/>

2.如果是SpringBoot项目,则需要在application.yml文件中,进行如下修改:

    server:
      port: 项目端口
      # 下面这个参数是为解决问题而新增的
      tomcat:
        max-http-header-size: 8192

可能是因为请求协议不对,需要统一成https或http请求。

非原创仅用于记录bug:原文传送门

相关标签: bug记录