stomp-raw

0.0.3 • Public • Published

stomp-raw

stomp-raw is a low level stomp library, working at the TCP text stream level, that allows writing valid STOMP protocol messages but also allows writing invalid STOMP messages.

This tool is used for negative testing of xtomp it should be useful for testing any STOMP broker.

The following example shows testing sending STOMP heart-beats (single '\n').

const StompRaw = require('stomp-raw').StompRaw;

const stompRaw = new StompRaw();

stompRaw.on("connect", function() {
    stompRaw.write("CONNECT\n\n\0");
});

stompRaw.on("frame", function(frame) {

    while (frame.charAt(0) === '\n' || frame.charAt(0) === '\r') {
        console.log("leading whitespace detected");
        frame = frame.substring(1);
    }

    if ( frame.startsWith("CONNECTED") ) {
        setInterval(() => {

            stompRaw.write("\n");

        }, 50);

        setTimeout(() => {
            stompRaw.write("SEND\ndestination:memtop-a\n\nmessage data\0");
        }, 100);

        setTimeout(() => {
            stompRaw.end();
            process.exit(0);
        }, 500);

    }
    else {
        console.log("error");
        stompRaw.end();
    }
});

stompRaw.connect();

xtomp on github

Package Sidebar

Install

npm i stomp-raw

Weekly Downloads

10

Version

0.0.3

License

GPL-3.0

Last publish

Collaborators

  • teknopaul