gpt4 book ai didi

java - 如何解决 "Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]"?

转载 作者:行者123 更新时间:2023-12-04 04:00:07 32 4
gpt4 key购买 nike

将 SpringBoot 项目部署到 AWS EC2 实例后,经常出现异常:

2020-07-31 01:56:21.487 DEBUG 7340 --- [nio-8080-exec-1] o.a.tomcat.util.net.SocketWrapperBase    : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@3d89313d:org.apache.tomcat.util.net.NioChannel@11d95ea0:java.nio.channels.SocketChannel[connected local=/172.31.38.151:8080 remote=/198.98.61.139:33842]], Read from buffer: [0]
2020-07-31 01:56:21.487 DEBUG 7340 --- [nio-8080-exec-1] org.apache.tomcat.util.net.NioEndpoint : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@3d89313d:org.apache.tomcat.util.net.NioChannel@11d95ea0:java.nio.channels.SocketChannel[connected local=/172.31.38.151:8080 remote=/198.98.61.139:33842]], Read direct from socket: [175]

2020-07-31 01:56:21.487 INFO 28770 --- [nio-8080-exec-4] 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 the HTTP protocol [HTTP/1.10x0aHost:]
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:560) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
它不会破坏项目,并且每个功能都运行良好。
但是不知道以后会不会引起一些问题,所以想现在就解决。
谁能给我一些有关导致此异常的原因的提示?

最佳答案

我遇到了同样的问题,发现它与 8.5.44 版中引入的对 Tomcat 8.5 的更改有关。对此的描述是Fix: 63578: Improve handling of invalid requests so that 400 responses are returned to the client rather than 500 responses. (markt) ( http://tomcat.apache.org/tomcat-8.5-doc/changelog.html#Tomcat_8.5.44_(markt) )
在这种情况下,一些向 HTTP GET 端点发出手动请求的遗留代码正在发送如下内容:"GET " + path + " HTTP/1.1\n"这需要更改为:"GET " + path + " HTTP/1.1\r\n"解决问题。
将详细信息放在这里,以供将来有相同问题的其他人引用。 Tomcat 会修复此问题以使其更加合规,这可能会破坏未做正确事情的遗留代码。

关于java - 如何解决 "Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63184425/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com