Hi
I want my UI to subscribe to the output stream using websockets.
But I am unable to open the websocket connection due 'authorization missing (HTTP Code 401)' error. Since UI uses javascript, providing headers in websocket connection is not an option. The document says following:
If your WebSocket client does not support setting headers, include your credentials as the first element of the JSON map when requesting authorization
But how can this be achieved since the connection is closed?
Here is the code:
var ws = new WebSocket("wss://host:port/1/workspaces/default/projects/myProject/subscriber"); ws.onopen = function() { alert("WebSocket connection!"); ws.send(JSON.stringify(authorizationRequest)); }; ws.onmessage = function (evt) { var received_msg = evt.data; alert(received_msg); }; ws.onclose = function() { // websocket is closed. alert("Connection is closed...");};
Thanks!