【发布时间】:2017-06-27 08:10:03
【问题描述】:
我正在使用 aiohttp 开发 websocket,我可以使用 run_app 方法正常工作,并且使用以下命令可以很好地使用 gunicorn。
gunicorn wsredis:app --bind 0.0.0.0:1234 --worker-class aiohttp.worker.GunicornWebWorker
当我这样做连接到套接字时,我得到了这个响应。
Content-Type: application/octet-stream
Upgrade: websocket
Connection: upgrade
Transfer-Encoding: chunked
Sec-Websocket-Accept: sMOPKXQxUMYzguN7KBnuJxEQqFY=
Date: Tue, 27 Jun 2017 07:53:03 GMT
Server: Python/3.5 aiohttp/1.3.3
当我尝试让 websocket 在后台运行时,问题就来了。
所以如果我做
gunicorn wsredis:app --bind 0.0.0.0:1234 --worker-class aiohttp.worker.GunicornWebWorker &
在我退出 ssh 会话之前,它的工作方式相同。然后我从服务器收到了这个响应。
Content-Type: text/html; charset=utf-8
Content-Length: 170
Connection: close
Date: Tue, 27 Jun 2017 08:06:51 GMT
Server: Python/3.5 aiohttp/1.3.3
谁知道我做错了什么? 我尝试在nginx下做一个反向代理,但也没有用。
【问题讨论】:
标签: nginx python-3.5 gunicorn aiohttp