Socket Javascript does not connect (Stomp + RabbitMQ)

3

I'm trying to establish a communication between RabbitMQ and Javascript, to retrieve the log information that is sent to a RabbitMQ topic, but to no avail. In the console the following information is displayed:

Opening Web Socket...
WebSocket connection to 'ws://10.224.200.196:61613/' failed: WebSocket opening handshake timed out
Whoops! Lost connection to ws://10.224.200.196:61613/

This is my code for connecting to Javascript:

   var test = {
            client: null,
            onConnect: function () {
                client.subscribe("add-on", this.onMessage, {ack: 'client'});
                console.log('connected');
            },
            onMessage: function (message) {
                console.log(message);
                message.ack();
            },
            onError: function () {
                console.log('error');
            },
            connect: function () {
                this.client = Stomp.client('ws://10.224.200.196:61613/', 'v11.stomp');
                this.client.connect('test', 'test', this.onConnect, this.onError, '/');
            }
        };
        test.connect();

The user is created in RabbitMQ as "monitoring"

Thestomppluginhasbeenenabled

I'vealreadycreatedthetopicthroughRabbitMQ

IgetthesemessagesintheRabbitMQlog.

=INFOREPORT====4-Oct-2017::08:05:07===acceptingSTOMPconnection<0.672.0>(10.224.200.188:56652->10.224.200.196:61613)=INFOREPORT====4-Oct-2017::08:09:07===closingSTOMPconnection<0.672.0>(10.224.200.188:56652->10.224.200.196:61613)

HowdoIconnectandreceivemessages?

Ihavealreadyusedseveraltutorials,thelastonesbeing:

link

link

    
asked by anonymous 04.10.2017 / 13:16

1 answer

1

This problem happens because of the connection port that should be "15674".

Change the code:

this.client = Stomp.client('ws://10.224.200.196:61613/', 'v11.stomp');

By:

this.client = Stomp.client('ws://10.224.200.196:15674/ws', 'v11.stomp');

Here is an example of the changed code:

var test = {
        client: null,
        onConnect: function () {
            client.subscribe("/topic/add-on", this.onMessage, {ack: 'client'});
            console.log('connected');
        },
        onMessage: function (message) {
            console.log(message);
            message.ack();
        },
        onError: function () {
            console.log('error');
        },
        connect: function () {
            client = Stomp.client('ws://10.224.200.196:15674/ws', 'v11.stomp');
            client.connect('test', 'test', this.onConnect, this.onError, '/');
        }
    };
    test.connect();

Follow the documentation link

link

    
04.10.2017 / 14:28