복붙노트

[SPRING] Spring WebSocket : 잘못된 업그레이드 헤더로 인해 핸드 셰이크가 실패했습니다 : null

SPRING

Spring WebSocket : 잘못된 업그레이드 헤더로 인해 핸드 셰이크가 실패했습니다 : null

나는 스프링 백엔드와 STOMP에서 자바 스크립트 클라이언트 용 wss (보안 웹 소켓)을 사용하고있다.

아무도 이유를 알 수 있습니까?

Handshake failed due to invalid Upgrade header: null

해결법

  1. ==============================

    1.나는 바람둥이에 nginx의 https 프록시와 같은 문제를 만났습니다. 이것은 wss 요청을 지원하지 않았기 때문입니다. wss 요청을 지원하기 위해 아래 설정을 사용합니다.

    나는 바람둥이에 nginx의 https 프록시와 같은 문제를 만났습니다. 이것은 wss 요청을 지원하지 않았기 때문입니다. wss 요청을 지원하기 위해 아래 설정을 사용합니다.

    # 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";
        }
    }
    
  2. ==============================

    2.마지막으로 해결책을 찾았습니다.

    마지막으로 해결책을 찾았습니다.

    wss 요청을 처리하기 위해 Tomcat에서 https 포트를 열어야했습니다.

  3. from https://stackoverflow.com/questions/31211919/spring-websocket-handshake-failed-due-to-invalid-upgrade-header-null by cc-by-sa and MIT license