如何部署aiohttp websocket?
How to deploy aiohttp websocket?
我正在使用 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下做了一个反向代理,但是也没用。
已解决:
问题是我在脚本中有一些打印语句,所以当我退出 ssh 时。脚本无法打印并引发异常。
解决方案是删除打印语句并改为添加日志记录
我正在使用 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下做了一个反向代理,但是也没用。
已解决:
问题是我在脚本中有一些打印语句,所以当我退出 ssh 时。脚本无法打印并引发异常。
解决方案是删除打印语句并改为添加日志记录