javascriptwebsocketwamp-protocol

wampy subscribe is not getting published message


I'm implementing crossbar.io with wampy.js as client, i created webpage with the following code for subscribing to a topic called grp.69. However, i can publish to the topic, but im unable to read or get messages published to that topic.

I get the message that i successfully subscribed to the topic. On the router i get the message that a subscription was added to the topic grp.69

Here is my code

const ws = new Wampy('ws://127.0.0.1:9090/', { 
                                                   realm: 'realm1' ,
                                                   helloCustomDetails: 'LPM'
                                                  });

    ws.options({
            reconnectInterval: 1000,
            maxRetries: 999,
            onConnect: onCon
           });

    ws.subscribe('grp.69', {
        onSuccess: function() 
            { 
                console.log('Received grp.69 event!'); 
            },
        onError: function(err)
            {
                console.log('Error on subscribing: ' + err.error);
            },
        onEvent: function(result)
            {
                console.log('Received Event');
                console.log(result);
            }
        });

Solution

  • I got this solved, for everyone to check.

    What i was missing is that i can have a subscribe object, to the same topic and publishing. Because the onEvent is not being fired for the subscribe, its firing for the publish.

    However a workaround to have both, subscribe and publish to the same topic, is to have one object to manage subscriptions and second object to manage publish.