Invalid SockJS Path.
Invalid SockJS path βXXXβ required to have 3 path segments.
ꡬκΈμ Invalid SockJS path λΌλ ν€μλλ‘ κ²μν΄λ³΄λ©΄ μ΄μ κ°μ μ€λ₯ λ‘κ·Έμ λν μ‘°μΉλ‘ Stomp ν΄λΌμ΄μΈνΈλ₯Ό μ¬μ©νλΌλ λ΅λ³μ΄λ μ€ν μ€λ²νλ‘μ°μ μ§λ¬ΈνλΌλ λ΅λ³μ μ°Ύμλ³Ό μ μλ€. μλ¬΄νΌ μ μν©μ λν μμΈμ λͺ νν μ μ μλ μν©μμ μλμ κ°μ ꡬ쑰μμ ν΄λΉ μ€λ₯κ° λ°μνλ€.
- Nginx Websocket Proxy
- Spring WebSocket with Stomp + SockJS
sockjs-client@1.6.1
@stomp/stompjs@7.0.0
μ΄μ νμ
nginx.confμ κ°μ΄ μμ§μμ€μμ μΉμμΌ μ£Όμ ν¨ν΄μ λν΄ λ°±μλ μ ν리μΌμ΄μ
μΌλ‘μ 리λ²μ€ νλ‘μ ꡬμ±μ μλμ κ°μ΄ ν΄λ μνμλ€. κ·Έλ¦¬κ³ Stomp λ°©μμ μΉ μμΌ μ°κ²°μ μννλ μλν¬μΈνΈλ /ws/stomp
λ‘ μ μλμ΄μμλ€. λ³Έλ /ws
λ μΌλ°μ μΈ μΉ μμΌ μ°κ²°μ μννκ³ /ws/stmop
λ‘ μμλλ κ²μ Stompλ‘ λμνλ κ²μ μλν κ²μ΄λ€.
nginx.confhttp { upstream backend { server app:8080; keepalive 128; } server { location /ws/ { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # hop-by-hop proxy_http_version 1.1; proxy_set_header Connection "upgrade"; proxy_set_header Upgrade $http_upgrade; proxy_read_timeout 65s; } } }
Vite κ°λ° μλ²μμμ Proxy ꡬμ±μ κ²½μ° μ¬λ°λ₯΄κ² Stomp λ°©μμ μΉμμΌ μ°κ²°μ μνλλ€.
νμ§λ§, μμ§μμ€μ ν¨κ» λμμ€μΈ λ°°ν¬ νκ²½μμλ Stomp ν΄λΌμ΄μΈνΈκ° SockJSλ₯Ό μ¬μ©νμ¬ μ°κ²°μ μννλ €κ³ ν λ /ws/stomp/info?t=0
μλν¬μΈνΈμ λν΄ 404 μλ΅μ λ°κ²λκ³ μ ν리μΌμ΄μ
λ‘κ·Έμλ Invalid SockJS path ...
κ° μΆλ ₯λλ κ²μ νμΈνλ€.
μ루μ
μ΄λ¦¬μ 리 μλν΄λ³Έ κ²°κ³Ό ν΄κ²°μ±
μ μΌλ°μ μΈ μΉ μμΌ μ°κ²°κ³Ό Stomp λ°©μμ μ°κ²°μ μμ λΆλ¦¬νλ κ²μ΄λ€. /ws/
μ΄μΈμ /ws-stomp/
λ‘ Stomp λ°©μμ μΉ μμΌ μ°κ²°μ μν λ³λμ μλν¬μΈνΈ ν¨ν΄μ μ¬μ©νκ³ λ¦¬λ²μ€ νλ‘μ ꡬμ±μ νκ³ λλ ν΄λΉ μ¦μμ λ°μνμ§ μμλ€.
nginx.confhttp { upstream backend { server app:8080; keepalive 128; } server { location ~ ^/(ws|ws-stomp)/ { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # hop-by-hop proxy_http_version 1.1; proxy_set_header Connection "upgrade"; proxy_set_header Upgrade $http_upgrade; proxy_read_timeout 65s; } } }
μλ¬΄νΌ μ νν μμΈμ λν΄μλ λ³λλ‘ μ°Ύμ보μμΌκ² μ§λ§ κΈ°λ‘μΌλ‘ λ¨κΈ°κ³ μ νλ€.