Skip to content

Support for node.js app for TCP and Web Sockets

Compare
Choose a tag to compare
@jmesnil jmesnil released this 25 Sep 09:38

Stomp.js can now be used in node.js app to connect to STOMP brokers over TCP socket or Web Sockets

Install the package:

$ npm install stompjs

In the node.js app, require the module with:

var Stomp = require('stompjs');

To connect to a STOMP broker over a TCP socket, use the Stomp.overTCP(host, port) method:

var client = Stomp.overTCP('localhost', 61613);

To connect to a STOMP broker over a WebSocket, use instead the Stomp.overWS(url) method:

var client = Stomp.overWS('ws://localhost:61614');

Apart from this initialization, the STOMP API remains the same whether it is running in a Web browser or in node.js application.