Web-Stomp Web browser communication

RabbitMQ is a message broker that allows clients to connect over a range of different open and standardized protocols such as AMQP, HTTP, STOMP, MQTT, MQTT over websockets and WebSockets/Web-Stomp.

Web-Stomp is a plugin to RabbitMQ which exposes a WebSockets server (with fallback) so that web browsers can communicate with your RabbitMQ server/cluster directly.

The Web-Stomp plugin can only be enabled on dedicated plans.

To use Web-Stomp, you first need to create at least one user, with limited permissions or a new vhost, which you can expose publicly. The username/password must be included in your javascript file, and you don't want a nonlimited user to subscribe or publish to queues or exchanges.

Next include stomp.min.js in your HTML from for example CDNJS:

<script src="//cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>

To connect:

// Replace with your hostname
var wss = new WebSocket("wss://blue-horse.rmq.cloudamqp.com/ws/");
var client = Stomp.over(wss);

// RabbitMQ SockJS does not support heartbeats so disable them
client.heartbeat.outgoing = 0;
client.heartbeat.incoming = 0;

client.debug = onDebug;

// Make sure the user has limited access rights
client.connect("webstomp-user", "webstomp-password", onConnect, onError, "vhost");

function onConnect() {
  var id = client.subscribe("/exchange/web/chat", function(d) {
    var node = document.createTextNode(d.body + '\n');

function sendMsg() {
  var msg = document.getElementById('msg').value;
  client.send('/exchange/web/chat', { "content-type": "text/plain" }, msg);

function onError(e) {
  console.log("STOMP ERROR", e);

function onDebug(m) {
  console.log("STOMP DEBUG", m);

A full example can be found here: github.com/cloudamqp/web-stomp-example

You can also use the WebSocket API directly: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

Note that our servers have nginx in front of them that will perform TLS/SSL-termination. You can only connect over HTTPS; HTTP is not allowed.

If you have any questions, please feel free to contact support@cloudamqp.com for further assistance.