Configuration

class stompest.config.StompConfig(uri, login=None, passcode=None, version=None, check=True, sslContext=None)

This is a container for those configuration options which are common to both clients (sync and async) and are needed to establish a STOMP connection. All parameters are available as attributes with the same name of this object.

Parameters:
  • uri – A failover URI as it is accepted by StompFailoverUri.
  • login – The login for the STOMP brokers. The default is None, which means that no login header will be sent.
  • passcode – The passcode for the STOMP brokers. The default is None, which means that no passcode header will be sent.
  • version – A valid STOMP protocol version, or None (equivalent to the DEFAULT_VERSION attribute of the StompSpec class).
  • check – Decides whether the StompSession object which is used to represent the STOMP sesion should be strict about the session’s state: (e.g., whether to allow calling the session’s send() when disconnected).
  • sslContext (ssl.SSLContext) – An SSL context to wrap around a TCP socket connection. This object is defined in the Python standard library: ssl.SSLContext

Note

Login and passcode have to be the same for all brokers because they are not part of the failover URI scheme.

See also

The StompFailoverTransport class which tells you which broker to use and how long you should wait to connect to it, the StompFailoverUri which parses failover transport URIs.

SSL Example

import ssl
sslContext = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
# It's good practice to disable insecure protocols by default. Note that
# since Python 3.6, SSLv3 is disabled by default.
sslContext.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_SSLv3

# For testing and development, it is often useful to disable host cert
# validation, which requires *both* of the following settings.
sslContext.check_hostname = False
sslContext.verify_mode = ssl.CERT_NONE

# Create the StompConfig as usual. Remember that for TLS/SSL, the URI should
# begin with "ssl"
config = StompConfig(
    'ssl://host.com',
    login='admin',
    passcode='admin',
    sslContext=sslContext
)