WebSocket打开握手在https中超时

西哈布丁KM

WebSocket与“ wss:// ip_address:8008 / ws / events?subscribe-broadcast”的连接失败: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

我的nginx配置是

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;
}
}

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

帕万船员

为了使Web套接字能够通过Tls(wss)协议工作,您需要生成ssl证书,在生成证书之后,将以下行添加到uwsgi.ini文件中。

https-socket=[ip]:[port], /path_to_server_certificate, /path_to_key

并重新启动服务器(可选地,您还可以再传递2个字段[,ciphers,ca]),可以在此处找到更多详细信息

另外,如果您的消息代理有能力,则可以使用Mqtt或Stomp等消息传递协议直接将其公开给客户端。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章