Using SuperWebSocket with socket.io (engine.io) or sock-js.

Jul 24, 2014 at 11:52 AM
Hi.

I run samples of SWS and try to use libraries like socket.io or sock.js and none of them works.
I use Chrome and something like simple samples:
<script src="engine.io.js"></script>
<script>
    var socket = new eio.Socket('http://172.17.0.91:2012', {rememberUpgrade: true});
    socket.on('open', function ()
    {
        console.log("opened");
        socket.on('message', function (data)
        {
            console.log(data);
        });
        socket.on('close', function ()
        {
            console.log("closed");
        });
    });

</script>
or
<script src="http://cdn.sockjs.org/sockjs-0.3.js"></script>

    <script>
        var sock = new SockJS('http://localhost:2012/',{debug:true});
        sock.onopen = function ()
        {
            console.log('open');
        };
        sock.onmessage = function (e)
        {
            console.log('message', e.data);
        };
        sock.onclose = function ()
        {
            console.log('close');
        }
    </script>
First of all, there is no message in Chrome console (in case if sock-js I see only close message). Meanwhile WebSockets directly works great,
var sock = new WebSocket('ws://localhost:2012/');
and so on.

What can be the cause of these libraries to not work properly, should I setup something special for SWS? Or the best practise to work with SWS is only with WebSocket browser object (in any) directly?

Thanks in advance.
Jul 25, 2014 at 12:39 PM
It seems, that I resolved issue in part of engine-io. It has it's own protocol which should be supported on the
server side. Nonetheless, I can use this lib only with websocket transport (provided in options). And it doesn't work with long polling -- it stucks, because first it tries to use long polling.
Do you plan to support long polling?
Jul 30, 2014 at 1:26 PM
Anyone?
Coordinator
Jul 31, 2014 at 2:29 PM
Yes, but it is not urgent.
Marked as answer by 18cc on 7/31/2014 at 8:36 AM