一、情况说明:
系统:Alibaba Cloud 3
服务器面板:宝塔
python版本:3.6.8
后端框架:FastAPI
核心依赖:FastAPI(0.83.0)、uvicorn (0.16.0)
启动命令:uvicorn main:app --reload --host 0.0.0.0 --port 8000 --reload
启动项目后,访问出现
Unsupported upgrade request.
并且客户端返回400 Bad Request
二、原因解析
通过pip install uvicorn来安装的uvicorn 0.16.0版本并没有带有websockets,要安装带有websockets功能的uvicorn需要使用pip install uvicorn[standard]来安装。
三、解决方案
1.先卸载uvicorn
pip uninstall uvicorn
2.再安装uvicorn[standard]
pip install uvicorn[standard]