Spring WebSocket:由于无效的升级标头,握手失败:null [英] Spring WebSocket: Handshake failed due to invalid Upgrade header: null
本文介绍了Spring WebSocket:由于无效的升级标头,握手失败:null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用wss(安全的Web套接字)以及来自后端的spring和用于JavaScript客户端的STOMP.
I am using wss (secured web sockets) with spring from backend and STOMP for javascript client.
有人知道为什么要得到吗?
Does anyone knows why a get:
Handshake failed due to invalid Upgrade header: null
推荐答案
我在使用tomcat的nginx https代理时遇到了同样的问题.这是因为我不支持wss请求.为了支持wss请求,我使用如下配置:
I met the same problem with nginx https proxy to tomcat. This is because I haven't support the wss request. To support the wss request, I use the config like below:
# WebSocketSecure SSL Endpoint
#
# The proxy is also an SSL endpoint for WSS and HTTPS connections.
# So the clients can use wss:// connections
# (e.g. from pages served via HTTPS) which work better with broken
# proxy servers, etc.
server {
listen 443;
# host name to respond to
server_name ws.example.com;
# your SSL configuration
ssl on;
ssl_certificate /etc/ssl/localcerts/ws.example.com.bundle.crt;
ssl_certificate_key /etc/ssl/localcerts/ws.example.com.key;
location / {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:8080
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
这篇关于Spring WebSocket:由于无效的升级标头,握手失败:null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文