How to enable WSS

583 views
Skip to first unread message

Chandan Pandey

unread,
Sep 4, 2013, 10:27:15 AM9/4/13
to soc...@googlegroups.com
I am using SockJS-client. SockJS constructor takes a relative URL as

var ws= new SockJS('/spring-websocket-test/sockjs/echo', undefined, {protocols_whitelist: [transport]});

Where do we indicate that WSS:// be used instead of WS://. If I try absolute URL, it gives error :

XMLHttpRequest cannot load ws://localhost:8080/appname/app. Cross origin requests are only supported for HTTP.

_ws_onclose. wasClean: false code: 1002 reason: Can't connect to server

Not sure why getting this error. Any similar configuration needed on Spring Server Implementation?

Chandan Pandey

unread,
Sep 16, 2013, 10:23:41 AM9/16/13
to soc...@googlegroups.com
I went through the client code -sock JS takes care of it -if its HTTPS it uses WSS else it does WS

    var that = this;
    var url = trans_url + '/websocket';
    if (url.slice(0, 5) === 'https') {
        url = 'wss' + url.slice(5);
    } else {
        url = 'ws' + url.slice(4);
    }

Also I noticed that it adds "/websocket" for connecting to the server. I was writing a Java based client (for load tests) using Jetty websocket-client and when I passed URL for my WS location, it would never connect! Addning "/websocket" at the end of URL solved it, either I have missed it else I think its not documented anywhere -seems a good point to be documented.
Reply all
Reply to author
Forward
0 new messages