HTTPS server
# nginx配置文件
server {
listen 443 ssl;
server_name wdestian0918.icu;
add_header Content-Security-Policy upgrade-insecure-requests;
ssl_certificate my.pem;
ssl_certificate_key my.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# WebSocket 请求
location /wx/ {
proxy_pass http://wdestian0918.icu:8080/wx/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
if ('WebSocket' in window) {
websocket = new WebSocket("ws://wdetian0918.icu/wx/B/A");
}
我是之前写成了,本机测试没用nginx代理。导致一直访问不到
if ('WebSocket' in window) {
websocket = new WebSocket("ws://wdetian0918.icu:8080/wx/B/A");
}
结果就是SSL_ERROR_RX_RECORD_TOO_LONG
还有人说是nginx
WebSocket 请求
location /wx/ { 要加斜杠
location /wx 不能是下面的
如果你的后台接口是这样的话
@ServerEndpoint("/wx/{fromOpenid}/{toOpenid}")