Skip to main content

This is a transport neutral client implementation of the STOMP protocol.

Project description


Oisin Mulvihill



This is a python client implementation of the STOMP protocol.

The client is attempting to be transport layer neutral. This module provides functions to create and parse STOMP messages in a programmatic fashion. The messages can be easily generated and parsed, however its up to the user to do the sending and receiving.

I’ve looked at the stomp client by Jason R. Briggs. I’ve based some of the ‘function to message’ generation on how his client does it. The client can be found at the follow address however it isn’t a dependency.

In testing this library I run against ActiveMQ project. The server runs in java, however its fairly standalone and easy to set up. The projects page is here:

Source Code

The code can be accessed via git on github. Further details can be found here:


Basic Usage

To see some basic code usage example see example/ The unit test tests/ illustrates how to use all aspects of the code.


The example and show how messages and generated and then transmitted using the twisted framework. Other frameworks could be used instead. The examples also demonstrate the state machine I used to determine a response to received messages.

I’ve also included and as examples of using the new stompbuffer module contributed by Ricky Iacovou.

Release Process

Submit a pull request with tests if possible. I’ll review and submit. All tests must pass. I tend to run against python3.7 nowadays. I will then increment the version, add attribute and then release to pypi if all is good.

Help Oisin remember the relase process:

# clean env for release:
mkvirtualenv --clear -p python3.7 stomper

# setup and run all tests:
python develop
python test

# Build and release to first:
pip install twine
python sdist bdist_wheel
twine upload --repository-url dist/*

# On success
twine upload dist/*

# Commit any changes and tag the release
git tag X.Y.Z

Supported STOMP Versions


This is the default version of the of STOMP used in stomper versions 0.3.x.


This is no longer the default protocol version. To use it you can import it as follows:

import stomper.stomp_10 as stomper

This is the default version used in stomper version 0.2.x.

Version History


Added missing attribution to contributors section and messed up 0.4.2 release to new pypi.


Thanks to for contributing a fix to include the license in the distribution. OM: Added minor fix to support uploading before releasing. Document my release process to help me next time around.


Thanks to Ralph Bean ( contributing a fix to and utf-8 encoding under python3.


Thanks to Lumír ‘Frenzy’ Balhar ( contributing python3 support.


This release makes STOMP v1.1 the default protocol. To stick with STOMP v1.0 you can continue to use stomper v0.2.9 or change the import in your code to:

import stomper.stomp_10 as stomper

Note Any fixes to STOMP v1.0 will only be applied to version >= 0.3.


Thanks to Ralph Bean for contributing the new protocol 1.1 support:


Thanks to Daniele Varrazzo for contributing the fixes:
  • Fixed newline prepended to messages without transaction id
  • Fixed reST syntax. Extension changed to allow github to render it properly. Also changed the source url in the readme.


I forgot to add a which makes sure is present. Without this pip install fails: Thanks to Ian Weller for noticing this. I’ve also added in the fix suggested by Arfrever


Add contributed fixes from Simon Chopin. He corrected many spelling mistakes throughout the code base. I’ve also made the the main


Add the contributed fix for issue #14 by Niki Pore. The issue was reported by Roger Hoover. This removes the extra line ending which can cause problems.


OM: A minor release fixing the problem whereby uuid would be installed on python2.5+. It is not needed after python2.4 as it comes with python. Arfrever Frehtes Taifersar Arahesis contributed the fix for this.


OM: I’ve fixed issue #9 with the example code. All messages are sent and received correctly.


  • Applied patch from esteve.fernandez to resolve “Issue 4: First Message not received” in the example code (

  • I’ve (Oisin) updated the examples to use twisted’s line receiver and got it to “detect” complete stomp messages. The old example would not work if a large amount of data was streamed. In this case dataReceived would be called with all the chunks of a message. This means that it would not be correct for it to attempt to unpack and react until the whole message has been received. Using twisted’s line receiver looking for the x00 works like a charm for this.

This release integrates the bug fixes and the optional stompbuffer contributed by Ricky Iacovou:

  • Removed the trailing ‘nn’ inserted by Frame.pack(). I believe that adding this is incorrect, for the following reasons: gives the example:

login: <username>


and comments, “the body is empty in this case”. This gives the impression that the body is exactly defined as “the bytes, if any, between the ‘nn’ at the end of the header and the null byte”.

This works for both binary and ASCII payloads: if I want to send a string without a newline, I should be able to, in which case the body should look like:

this is a string without a newline^@

… and the receiver should deal with this.

This impression is reinforced by the fact that ActiveMQ will complain if you supply a content-length header with any other byte count than that described above.

I am also unsure about the newline after the null byte as nothing in the protocol says that there should be a newline after the null byte. Much of the code in StompBuffer actively expects it to be there, but I suspect that relying on a frame ending ‘x00n’ may well limit compatibility. It’s not an issue with Stomper-to-Stomper communication, of course, as the sender puts it, the receiver accepts it, and ActiveMQ happily sends it along.

  • StompBuffer has had a few fixes; most notably, a fix that prevents a content-length “header” in the body from being picked up and used (!). The biggest change is a new method, syncBuffer(), which allows a corrupted buffer to recover from the corruption. Note that I’ve never actually seen the buffer corruption when using Twisted, but the thought occurred to me that a single corrupt buffer could hang the entire message handling process.

  • Fixed the typo “NO_REPONSE_NEEDED”. I’ve changed it to NO_RESPONSE_NEEDED, but kept the old variable for backwards compatibility;

  • I’ve also modified the string format in send() to include the ‘nn’ between the header and the body, which I think is missing (it currently has only one ‘n’).

  • Added CONNECTED to VALID_COMMANDS so syncBuffer() does not decide these messages are bogus.

  • Added new unit test file teststompbuffer which covers the new functionality.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stomper-0.4.3.tar.gz (29.3 kB view hashes)

Uploaded source

Built Distribution

stomper-0.4.3-py3-none-any.whl (37.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page