Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python AWS ec2&x2B;乌维康+;fastapi,我得到uvicorn错误_Python_Amazon Web Services_Fastapi_Uvicorn - Fatal编程技术网

Python AWS ec2&x2B;乌维康+;fastapi,我得到uvicorn错误

Python AWS ec2&x2B;乌维康+;fastapi,我得到uvicorn错误,python,amazon-web-services,fastapi,uvicorn,Python,Amazon Web Services,Fastapi,Uvicorn,我有一台本地运行的服务器。但当我在AWSEC2上运行它,并在端口8000上从外部发送请求时,我得到了这个错误 $ uvicorn sql_app.main:app --host="0.0.0.0" --port=8000 INFO: Started server process [9806] INFO: Waiting for application startup. INFO: Application startup complete. INFO:

我有一台本地运行的服务器。但当我在AWSEC2上运行它,并在端口8000上从外部发送请求时,我得到了这个错误

$ uvicorn sql_app.main:app --host="0.0.0.0" --port=8000
INFO:     Started server process [9806]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 170, in handle_events
    event = self.conn.next_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_readers.py", line 73, in maybe_read_from_IDLE_client
    request_line_re, lines[0], "illegal request line: {!r}", lines[0]
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_util.py", line 88, in validate
    raise LocalProtocolError(msg)
h11._util.RemoteProtocolError: illegal request line: bytearray(b'\x16\x03\x01\x02\x00\x01\x00\x01\xfc\x03\x03\x91\xa5\xe2Y\xf0\xa1\xdd\x1d+\x08\x1c\r\x15X\x1d@\x1e/\xb1N\x00\xb5\xe5\xec\xf3F\x1fm\x03\xa1{> \xa80\xb4\x14\x1aUs\xaa\xcd\xc3<s\xcd\xd1\x17\xdf3\x0e\xdbh\xd1c\x88}\x8c\x1f\xa5\x15\x9aa\x14I\x00 ')
WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 170, in handle_events
    event = self.conn.next_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
    raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line
WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 170, in handle_events
    event = self.conn.next_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
    raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line
WARNING:  Invalid HTTP request received.
$uvicorn sql\u app.main:app--host=“0.0.0.0”--端口=8000
信息:已启动服务器进程[9806]
信息:正在等待应用程序启动。
信息:应用程序启动完成。
信息:Uvicorn正在运行http://0.0.0.0:8000 (按CTRL+C退出)
警告:接收到无效的HTTP请求。
回溯(最近一次呼叫最后一次):
handle_events中的文件“/home/ec2 user/.local/lib/python3.7/site packages/uvicorn/protocols/http/h11_impl.py”,第170行
event=self.conn.next_event()
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_connection.py”,第443行,在下一个_事件中
exc.\u重新发送\u为\u远程\u协议\u错误()
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_util.py”,第76行,在远程协议中出错
自立
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_connection.py”,第425行,在下一个_事件中
事件=self.\u提取\u下一个\u接收\u事件()
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_connection.py”,第367行,在_extract\u next\u receive\u事件中
事件=self.\u读取器(self.\u接收\u缓冲区)
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_readers.py”,第73行,从空闲客户端读取
请求行,行[0],“非法请求行:{!r}”,行[0]
文件“/home/ec2 user/.local/lib/python3.7/site packages/h11/_util.py”,第88行,在validate中
引发本地协议错误(msg)
h11.\u util.RemoteProtocolError:非法请求行:bytearray(b'\x16\x03\x01\x02\x00\x01\xfc\x03\x03\x03\x91\xa5\xe2Y\xf0\xa1\xdd\x1d+\x08\x1c\r\x15X\x1d@\x1e/\xb1N\x00\xb5\xec\xf3F\x1fm\x03\xa1{>将默认值更改为<0

启动uvicorn时使用此标志

--超时保持活动状态0

我也遇到了同样的问题,并通过添加HTTPS支持解决了这个问题。我使用LetsEncrypt证书配置了NGINX。请确保您使用的端口在您的安全组设置中处于打开状态。

我收到了相同的神秘警告:接收到无效的HTTP请求。
错误,堆栈跟踪无效。我尝试了所有envi建议对环境变量进行调整,但没有任何调整有效(请参见)

我的问题是,当我调用FastAPI微服务时,我使用的是
https
,而我的微服务没有https支持。我将url从
https
更改为
http
,它开始按预期工作


请注意,如果您的服务需要HTTPS支持,您可以按照Ilgizar Murzakov的建议进行操作。

仍然不起作用``raise LocalProtocolError(msg)h11.\u util.RemoteProtocolError:非法请求行:bytearray3\x03\x03\x03\x03\x03\x03\x03\x03\X08\x03\x03\X08\X8 8\X8 8\X6\X6\X6\X6\X6\0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 8 8 8 8 8 8 \X8 8 8 8 8 \X8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 \X6 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 x8f\x00“\x9a\x9a\x13\x01\x13\x02\x13\x03\xc0+\xc0/\xc0\xc00\xcc\xa9\xcc\xa8\xc0\x13\x0\x14\x00\x9c\x00\x9d\x00/\x005\x00')```