javascript - Django 频道使用 ws:// 但无法与 wss:// 握手
问题描述
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,它工作正常。
解决方案
我启用了限制连接到 websocket 的 CORS 策略。禁用后它对我来说工作正常
推荐阅读
- java - Android Studio 抛出“线程“主”javax.net.ssl.SSLException 中的异常:收到致命警报:protocol_version”
- r - 如何在 R 中一次运行多个线性回归?
- xpath - 使用 Google 电子表格从网站中提取电子邮件
- loops - 在液体 if 语句中使用来自父液体循环的属性
- sql-server - 是否可以创建托管在谷歌云上的分区表 SQL Server?
- amazon-s3 - Lambda 跨账户对象复制 - HeadObject 操作:未找到
- c++ - 为什么 std::function 只有在异常转义当前函数时才会导致堆栈展开?
- javascript - 如何设置 jQuery easySelect.js 的选定值?
- mongodb - 在 spring 中配置 mongodbs dbrefs 的读取首选项
- ios - Flutter Internationalize/Localize iOS 不工作 XCode