AMQP over Websocket with LavinMQ

LavinMQ offers support for Websockets via: AMQP over Websockets.

What is AMQP over Websockets?

AMQP (Advanced Message Queuing Protocol) is an open standard application layer protocol used for reliable messaging between applications. LavinMQ was designed specifically to support AMQP as its core protocol.

Now, imagine you have a web application that needs to communicate with other AMQP-based systems. To enable this communication, you can use a messaging broker like LavinMQ. LavinMQ acts as the middleman, facilitating the exchange of messages between the web application and the systems.

But here’s the catch: web browsers don’t natively support AMQP. That’s where AMQP over Websocket comes in - It’s a clever solution that allows web browsers to route AMQP traffic over a Websocket connection. But...

What is a Websocket?

You might have heard of Websocket as the technology that enables real-time, bidirectional communication between a web browser and a server.

In simpler terms, think of it this way - unlike traditional web interactions where the browser sends a request and waits for a response, Websockets keep the connection open, allowing both the browser and the server to send messages to each other at any time. It’s as if they are having a continuous conversation, with information flowing back and forth in real-time.

Websocket is particularly useful for applications that require instant updates or real-time data, such as chat applications, collaborative tools, or live data streaming. With Websockets, information can be exchanged instantly without the need for repeated requests from the browser.

By combining AMQP with Websocket, you can establish a connection between the web browser and LavinMQ, just like a bridge.

This arrangement enables the web application to send and receive AMQP messages to and from other AMQP-based systems, even though the browser itself doesn’t directly support AMQP. It’s like giving the web application the ability to speak the same language as those systems.

AMQP over Websocket: How it works

Essentially, LavinMQ exposes a websocket endpoint via its HTTP server. The endpoint would accept Websocket packets and pass them to its internal Websocket module.

Functioning as a proxy, the Websocket module would convert the Websocket packets to AMQP frames that LavinMQ’s core protocol supports.

In a nutshell, LavinMQ supports Websockets via its built-in proxy that accepts Websocket packets and converts them to AMQP frames.

Connecting to LavinMQ via Websockets

When connecting to LavinMQ via AMQP Websockets, you should use a connection URL like:

const url = 'wss://'
const amqp = new AMQPWebsocketClient(url, "VHOST", "USERNAME", "YOUR_PASSWORD")

The URL above is for an instance running on CloudAMQP.

Now that we understand the basics of AMQP over Websockets, we will build a demo to demonstrate this concept of AMQP over Websocketk with LavinMQ in a future tutorial.

Ready to take the next steps? Here are some things you should keep in mind:

Managed LavinMQ instance on CloudAMQP

LavinMQ has been built with performance and ease of use in mind - we've benchmarked a throughput of about 1,000,000 messages/sec. You can try LavinMQ without any installation hassle by creating a free instance on CloudAMQP. Signing up is a breeze.

Help and feedback

We welcome your feedback and are eager to address any questions you may have about this piece or using LavinMQ. Join our Slack channel to connect with us directly. You can also find LavinMQ on GitHub.