Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.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
Django https中WebSocket打开握手超时_Django_Ssl_Nginx_Websocket_Uwsgi - Fatal编程技术网

Django https中WebSocket打开握手超时

Django https中WebSocket打开握手超时,django,ssl,nginx,websocket,uwsgi,Django,Ssl,Nginx,Websocket,Uwsgi,WebSocket连接到'wss://ip_address:8008/ws/events?subscribe-广播“失败:WebSocket打开握手超时 仅当在HTTPS中打开UI时,其超时,在HTTP中其工作… 我已经在ubuntu中使用OpenSSL生成了证书 我的uwsgi配置是 socket = /tmp/uwsgi.sock chmod-socket = 666 socket-timeout = 60 chdir = <django path> wsgi-fil

WebSocket连接到'wss://ip_address:8008/ws/events?subscribe-广播“失败:WebSocket打开握手超时

仅当在HTTPS中打开UI时,其超时,在HTTP中其工作…

我已经在ubuntu中使用OpenSSL生成了证书

我的uwsgi配置是

socket = /tmp/uwsgi.sock   
chmod-socket = 666  
socket-timeout = 60 
chdir = <django path>
wsgi-file  = <django_path>/wsgi.py
virtualenv = <path_to_virtualenv>
vacuum = true
enable-threads  = true
threads=500
startup-timeout = 15
graceful-timeout = 15
http-socket=<my_ip>:8008
http-websockets=true
server {
listen <ip>:80 default;
listen <ip>:443 ssl http2 default_server;
ssl_certificate <path>/generate_crt.crt;
ssl_certificate_key <path>/generated_key.key;
client_body_buffer_size 500M;
client_body_timeout 300s;
keepalive_timeout 5000;
client_max_body_size 700M;
access_log syslog:server=unix:/dev/log;
root /tmp/MVM_APPS/angularjs/dist;
index index.html index.htm;
server_name localhost;
location /api {
uwsgi_pass unix:///tmp/uwsgi.sock;
    include uwsgi_params;
    uwsgi_read_timeout 120;
    uwsgi_send_timeout 1000;
}
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass http://<ip>:8008;
proxy_read_timeout 86400;
}
location /static {
    alias /<path>/static;
}
location / {
    try_files $uri $uri/ /index.html;
}
}
socket=/tmp/uwsgi.sock
chmod插座=666
套接字超时=60
chdir=
wsgi文件=/wsgi.py
虚拟性=
真空=真
启用线程=true
螺纹=500
启动超时=15
正常超时=15
http套接字=:8008
http websockets=true
我的nginx配置是

socket = /tmp/uwsgi.sock   
chmod-socket = 666  
socket-timeout = 60 
chdir = <django path>
wsgi-file  = <django_path>/wsgi.py
virtualenv = <path_to_virtualenv>
vacuum = true
enable-threads  = true
threads=500
startup-timeout = 15
graceful-timeout = 15
http-socket=<my_ip>:8008
http-websockets=true
server {
listen <ip>:80 default;
listen <ip>:443 ssl http2 default_server;
ssl_certificate <path>/generate_crt.crt;
ssl_certificate_key <path>/generated_key.key;
client_body_buffer_size 500M;
client_body_timeout 300s;
keepalive_timeout 5000;
client_max_body_size 700M;
access_log syslog:server=unix:/dev/log;
root /tmp/MVM_APPS/angularjs/dist;
index index.html index.htm;
server_name localhost;
location /api {
uwsgi_pass unix:///tmp/uwsgi.sock;
    include uwsgi_params;
    uwsgi_read_timeout 120;
    uwsgi_send_timeout 1000;
}
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass http://<ip>:8008;
proxy_read_timeout 86400;
}
location /static {
    alias /<path>/static;
}
location / {
    try_files $uri $uri/ /index.html;
}
}
服务器{
听:80默认;
侦听:443sslhttp2默认_服务器;
ssl_证书/生成_crt.crt;
ssl\u证书\u密钥/生成的\u密钥.key;
客户体缓冲区尺寸500M;
客户端\u正文\u超时300s;
保持活动超时5000;
客户机最大机身尺寸700M;
访问日志syslog:server=unix:/dev/log;
root/tmp/MVM_APPS/angularjs/dist;
index.html index.htm;
服务器名称localhost;
地点/空气污染指数{
uwsgi_通道unix:///tmp/uwsgi.sock;
包括uwsgi_参数;
uwsgi_读取_超时120;
uwsgi_发送_超时1000;
}
地点/ws/{
proxy_http_版本1.1;
代理设置头升级$http\U升级;
代理集头连接升级;
代理传递http://:8008;
代理读取超时86400;
}
位置/静态{
别名//静态;
}
地点/{
尝试_文件$uri$uri//index.html;
}
}

我正在将Django与WS4redis软件包一起使用。

对于通过Tls(wss)协议工作的web套接字,您需要生成ssl证书,在生成证书后,将以下行添加到uwsgi.ini文件中

https-socket=[ip]:[port], /path_to_server_certificate, /path_to_key
然后重新启动服务器(也可以选择传递另外两个字段[,密码,ca]) 可以找到更多细节


或者,如果您的message broker是有能力的,您可以使用Mqtt或Stomp之类的消息传递协议直接将其公开给客户机,并将尝试它并让您知道更新…;-)哇,这救了我一天…;-)