【问题标题】:Django channels working with ws:// but fails to handshake with wss://Django 频道使用 ws:// 但无法与 wss:// 握手
【发布时间】:2020-03-02 21:16:32
【问题描述】:

nginx 设置

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name www.sample.co;
    return 301 https://$host$request_uri;
}
server {
    ssl on;
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name www.sample.co;
    rewrite ^(.*) https://beta.sample.co$1 permanent;
    ssl_certificate /home/ubuntu/certificate/certificate.crt;
    ssl_certificate_key /home/ubuntu/certificate/private.key;
    root /var/www/html;
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;
    server_name _;
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}

在达芙妮上运行

CMD ["daphne","-b","0.0.0.0","-p","8001","config.asgi:application"]

工作正常

ws://xyz.amazonaws.com/ws/sample/<sample-id>/

工作失败

wss://xyz.amazonaws.com/ws/sample/<sample-id>/

错误:

WebSocket 连接到 'wss://xyz.amazonaws.com/ws/sample//' 失败:错误 连接建立:net::ERR_CERT_COMMON_NAME_INVALID

应用程序在 AWS 上运行。从 https 调用 WebSocket。我尝试从本地的虚拟反应应用程序中使用 ws:// 调用 WebSocket,它工作正常。

【问题讨论】:

    标签: javascript django amazon-web-services websocket django-channels


    【解决方案1】:

    我启用了限制连接到 websocket 的 CORS 策略。禁用后它对我来说工作正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 2012-04-06
      • 2020-07-29
      • 2018-03-20
      • 1970-01-01
      • 2015-02-05
      • 2022-12-11
      相关资源
      最近更新 更多