I explained the details in Stackoverflow Post [1].
I use Spring Boot 2.0.0 Release as backend, SockjsClient 1.1.4, StompJs 2.3.3.
I want to use token based (jwt) authentication while connecting to websocket. As you may know, STOMP does not support http headers, so I would like to send my token in payload. Then, I will parse the nativeHeaders of payload within my ChannelInterceptor class. However,
When STOMP tries to connect websocket, it fails and the consol output is below.
Opening Web Socket...stomp.min.js:8:1737
XHRGET http://192.168.0.58:8080/api/v3/websocket/info?t=1523523409064 [HTTP/1.1 200 14ms]
XHRGET http://192.168.0.58:8080/api/v3/websocket/181/q2ln1go4/eventsource
XHRGET http://192.168.0.58:8080/api/v3/websocket/181/ebux3w0b/eventsource
XHRPOST http://192.168.0.58:8080/api/v3/websocket/181/s5uv2w1e/xhr?t=1523523412548
Whoops! Lost connection to http://192.168.0.58:8080/api/v3/websocket stomp.min.js:8:1737
If, I make wait 2 seconds before returning the info request on Server side, STOMP successfully connects and subscribes. The console output;
Opening Web Socket... stomp.min.js:8:1737
XHRGET http://192.168.0.58:8080/api/v3/websocket/info?t=1523523529512 [HTTP/1.1 200 2012ms]
Web Socket Opened... stomp.min.js:8:1737
>>> CONNECT
x-auth-token:{{my_token}}
accept-version:1.1,1.0
heart-beat:0,10000
� stomp.min.js:8:1737
<<< CONNECTED
version:1.1
heart-beat:0,0
user-name:admin
� stomp.min.js:8:1737
connected to server undefined stomp.min.js:8:1737
>>> SUBSCRIBE
id:sub-0
destination:/user/queue/admin
�
Does anyone has an idea? Also I'm wondering what is the purpose of /eventsource requests? Because, if I wait 2 seconds or not, the response of /info requests same. If server returns 10-20ms, stomp starts to make /eventsource request, however If the response of/info requests took ~2 seconds, it did not.
Hi,
I explained the details in Stackoverflow Post [1]. I use Spring Boot 2.0.0 Release as backend, SockjsClient 1.1.4, StompJs 2.3.3. I want to use token based (jwt) authentication while connecting to websocket. As you may know, STOMP does not support http headers, so I would like to send my token in payload. Then, I will parse the
nativeHeaders
of payload within myChannelInterceptor
class. However,When STOMP tries to connect websocket, it fails and the consol output is below.
If, I make wait 2 seconds before returning the info request on Server side, STOMP successfully connects and subscribes. The console output;
Does anyone has an idea? Also I'm wondering what is the purpose of
/eventsource
requests? Because, if I wait 2 seconds or not, the response of/info
requests same. If server returns 10-20ms, stomp starts to make/eventsource
request, however If the response of/info
requests took ~2 seconds, it did not.[1] = https://stackoverflow.com/questions/49774655/spring-security-and-websocket-with-jwt-token