【发布时间】:2022-01-15 23:14:57
【问题描述】:
我有一个 React 前端向运行 FastAPI 的 Discord.py 机器人发出请求。我的测试环境一切正常,但是当我部署到远程主机时,uvicorn 抱怨
WARNING: Invalid HTTP request received.
Traceback (most recent call last):
File "/home/container/uvicorn/protocols/http/h11_impl.py", line 136, in handle_events
event = self.conn.next_event()
File "/home/container/h11/_connection.py", line 443, in next_event
exc._reraise_as_remote_protocol_error()
File "/home/container/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
raise self
File "/home/container/h11/_connection.py", line 425, in next_event
event = self._extract_next_receive_event()
File "/home/container/h11/_connection.py", line 367, in _extract_next_receive_event
event = self._reader(self._receive_buffer)
File "/home/container/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line
2022-01-15 22:59:11,310 - Invalid HTTP request received.
Traceback (most recent call last):
File "/home/container/uvicorn/protocols/http/h11_impl.py", line 136, in handle_events
event = self.conn.next_event()
File "/home/container/h11/_connection.py", line 443, in next_event
exc._reraise_as_remote_protocol_error()
File "/home/container/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
raise self
File "/home/container/h11/_connection.py", line 425, in next_event
event = self._extract_next_receive_event()
File "/home/container/h11/_connection.py", line 367, in _extract_next_receive_event
event = self._reader(self._receive_buffer)
File "/home/container/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line
另外,如果我通过 Postman 提出请求,一切都会再次正常运行。这是我的主机的问题,还是我缺少一些 uvicorn 配置?
【问题讨论】: