Reputation: 557
I am writing a chat application without explicit server side web socket. I am using RabbitMQ webstomp as the web socket container and plain Javascript as the cleint to both send and receive data.
Below is the flow : Browser -> native websocket/sockjs -> rabbitmq /sockjs websocket (ws://127.0.0.1:15674/ws or http://localhost:15674/stomp) -> put messages to queue.
However while testing the application, I am not able to send the data directly to ws://127.0.0.1:15674/ws. I am just able to connect to it.
I use the below template to send and receive data on client Javascript.
Upvotes: 0
Views: 3678
Reputation: 22682
The problem,most likely,in your code is:
client.send(queue, {'reply-to':'/temp-queue/logs',priority: 9}, "msg" );
you have to send the message to a topic
I suggest to see the example here: https://github.com/rabbitmq/rabbitmq-web-stomp-examples
Here is a rapid example i made starting for the original example:
var client = Stomp.client('ws://localhost:15674/ws');
client.debug = pipe('#second');
var print_first = pipe('#first', function(data) {
client.send('/topic/test', {"content-type":"text/plain"}, data);
});
var on_connect = function(x) {
id = client.subscribe("/topic/test", function(d) {
print_first(d.body);
});
};
var on_error = function() {
console.log('error');
};
client.connect('guest', 'guest', on_connect, on_error, '/');
Upvotes: 0