linux 部署django项目时出错: WebSocket connection,Unexpected response code: 200"
2017-08-04 12:04
549 查看
在这个项目中用到了dwebsocket,而部署是利用nginx和uwsgi,在Windows下是正常的,但一移植到linux下就报上面的错误,其实解决方法很简单:
nginx配置:
location /{
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
uwsgi_read_timeout 2;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";}
增加下面这3行
uwsgi配置:
在uwsgi.ini文件最后增加:
async = 30
ugreen = ''
http-timeout = 300
这3行是允许uwsgi异步执行的
之后views.py里面响应的视图函数不变,html里面js:
'echo_once'对应相应的路由和响应函数
最后在settings.py增加:
重启nginx和uwsgi之后问题解决了
nginx配置:
location /{
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
uwsgi_read_timeout 2;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";}
增加下面这3行
uwsgi配置:
在uwsgi.ini文件最后增加:
async = 30
ugreen = ''
http-timeout = 300
这3行是允许uwsgi异步执行的
之后views.py里面响应的视图函数不变,html里面js:
var socket = new WebSocket("ws://" + window.location.host + "/echo_once");
'echo_once'对应相应的路由和响应函数
最后在settings.py增加:
WEBSOCKET_FACTORY_CLASS = 'dwebsocket.backends.uwsgi.factory.uWsgiWebSocketFactory'
重启nginx和uwsgi之后问题解决了
相关文章推荐
- WebSocket connection to,Error during WebSocket handshake: Unexpected response code: 404
- WebSocket connection to,Error during WebSocket handshake: Unexpected response code: 404
- WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"
- WebSocket Unexpected response code: 500
- Linux-web项目部署,django1.9跑django1.11的项目,报错
- WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"
- WebSocket Unexpected response code: 500
- Linux系统使用weblogic服务器部署web项目
- Linux 下部署Django项目
- web项目在linux环境下的部署
- Linux下部署Tomcat ,然后部署web项目
- linux上部署web项目
- Linux环境下Web项目的安装与部署过程
- vs .net 2005 打开VSS项目时出现:"could not find the visual sourcesafe internet web service connection"的解决方案
- Linux部署nodejs web项目
- Linux下将Python的Django项目部署到Apache服务器
- Linux web项目部署调试常用命令行
- Web 部署项目--VS2005的"郁闷"
- Linux下部署web项目实战
- WEB项目部署到Linux下无法访问html、css、js等静态文件的解决