前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >项目半夜凌晨宕机,报错Invalid character found in method name. HTTP method names must be tokens|the HTTP protoco

项目半夜凌晨宕机,报错Invalid character found in method name. HTTP method names must be tokens|the HTTP protoco

作者头像
全栈程序员站长
发布2022-09-14 12:55:46
2.2K0
发布2022-09-14 12:55:46
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

这几天项目总是在凌晨挂机,查看日志发现以下错误:

代码语言:javascript
复制
Http11Processor - Error parsing HTTP request header
 Note: further occurrences of HTTP header 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:426)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:687)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

Http11Processor - Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol
        at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:533)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:687)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

那么可能需要通过以下两种方式解决:

一、Tomcat的header缓冲区大小不够,只需要在server.xml中增加maxHttpHeaderSize字段即可:

代码语言:javascript
复制
<Connector URIEncoding="UTF-8" port="8080"                     
        protocol="org.apache.coyote.http11.Http11NioProtocol"
        useBodyEncodingForURI="false"
        enableLookups="false"
        connectionTimeout="20000"
        redirectPort="8443" maxHttpHeaderSize="你想要的大小"/>

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

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

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

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/159716.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档