Session is not open when connecting to autobahn js

1k views Asked by At

I'm having trouble while developing chat-like feature to my socket server.

First let me give you a little bit of my code:

document.conn = new ab.Session('ws://127.0.0.1:8090',
    function () {
        console.log('AB:Connected!');
        conn.subscribe('room_1', function (topic, data) {
            console.log('New message published to room "' + topic + '" : ' + data.content + ' by:' );
            console.log(data);
        });
    },
    function () {
        console.warn('WebSocket connection closed');
    },
    {'skipSubprotocolCheck': true}
);

Currently it's attached to document just to try it out, the error I'm getting is as follows:

"Session not open"

I'm a bit confused about this error and it's origin, should I somehow define the connection?

1

There are 1 answers

0
defo On

do you start your socket server through cmd.exe ?

you need to use this command to start the server:

php c://wamp64/www/yourproject/bin/push-server.php