Module autobahn.wamp

WAMP Interfaces

class autobahn.wamp.interfaces.IMessage[source]
abstract property MESSAGE_TYPE

WAMP message type code.

abstract static parse(wmsg)[source]

Factory method that parses a unserialized raw message (as returned byte autobahn.interfaces.ISerializer.unserialize()) into an instance of this class.

Returns

The parsed WAMP message.

Return type

object implementing autobahn.wamp.interfaces.IMessage

abstract serialize(serializer)[source]

Serialize this object into a wire level bytes representation and cache the resulting bytes. If the cache already contains an entry for the given serializer, return the cached representation directly.

Parameters

serializer (object implementing autobahn.wamp.interfaces.ISerializer) – The wire level serializer to use.

Returns

The serialized bytes.

Return type

bytes

abstract uncache()[source]

Resets the serialization cache for this message.

class autobahn.wamp.interfaces.IObjectSerializer[source]

Raw Python object serialization and deserialization. Object serializers are used by classes implementing WAMP serializers, that is instances of autobahn.wamp.interfaces.ISerializer.

abstract property BINARY

Flag (read-only) to indicate if serializer requires a binary clean transport or if UTF8 transparency is sufficient.

abstract serialize(obj)[source]

Serialize an object to a byte string.

Parameters

obj (any (serializable type)) – Object to serialize.

Returns

Serialized bytes.

Return type

bytes

abstract unserialize(payload)[source]

Unserialize objects from a byte string.

Parameters

payload (bytes) – Objects to unserialize.

Returns

List of (raw) objects unserialized.

Return type

list

class autobahn.wamp.interfaces.IPayloadCodec[source]

WAMP payload codecs are used with WAMP payload transparency mode.

In payload transparency mode, application payloads are transmitted “raw”, as binary strings, without any processing at the WAMP router.

Payload transparency can be used eg for these use cases:

  • end-to-end encryption of application payloads (WAMP-cryptobox)

  • using serializers with custom user types, where the serializer and the serializer implementation has native support for serializing custom types (such as CBOR)

  • transmitting MQTT payloads within WAMP, when the WAMP router is providing a MQTT-WAMP bridge

abstract decode(is_originating, uri, encoded_payload)[source]

Decode application payload.

Parameters
  • is_originating (bool) – Flag indicating whether the encoding is to be done from an originator (a caller or publisher).

  • uri (str) – The WAMP URI associated with the WAMP message for which the payload is to be encoded (eg topic or procedure).

  • payload (instance of autobahn.wamp.types.EncodedPayload) – The encoded application payload to be decoded.

Returns

A tuple with the decoded positional and keyword-based application payload: (uri, args, kwargs)

Return type

tuple

abstract encode(is_originating, uri, args=None, kwargs=None)[source]

Encodes application payload.

Parameters
  • is_originating (bool) – Flag indicating whether the encoding is to be done from an originator (a caller or publisher).

  • uri (str) – The WAMP URI associated with the WAMP message for which the payload is to be encoded (eg topic or procedure).

  • args (list or None) – Positional application payload.

  • kwargs (dict or None) – Keyword-based application payload.

Returns

The encoded application payload or None to signal no encoding should be used.

Return type

instance of autobahn.wamp.types.EncodedPayload

class autobahn.wamp.interfaces.ISerializer[source]

WAMP message serialization and deserialization.

abstract property MESSAGE_TYPE_MAP

Mapping of WAMP message type codes to WAMP message classes.

abstract property SERIALIZER_ID

The WAMP serialization format ID.

abstract serialize(message)[source]

Serializes a WAMP message to bytes for sending over a transport.

Parameters

message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message to be serialized.

Returns

A pair (payload, isBinary).

Return type

tuple

abstract unserialize(payload, isBinary)[source]

Deserialize bytes from a transport and parse into WAMP messages.

Parameters
  • payload (bytes) – Byte string from wire.

  • is_binary (bool) – Type of payload. True if payload is a binary string, else the payload is UTF-8 encoded Unicode text.

Returns

List of a.w.m.Message objects.

Return type

list

class autobahn.wamp.interfaces.ISession(config=None)[source]

Interface for WAMP sessions.

Parameters

config (instance of autobahn.wamp.types.ComponentConfig.) – Configuration for session.

abstract call(procedure, *args, **kwargs)[source]

Call a remote procedure.

This will return a Deferred/Future, that when resolved, provides the actual result returned by the called remote procedure.

  • If the result is a single positional return value, it’ll be returned “as-is”.

  • If the result contains multiple positional return values or keyword return values, the result is wrapped in an instance of autobahn.wamp.types.CallResult.

  • If the call fails, the returned Deferred/Future will be rejected with an instance of autobahn.wamp.exception.ApplicationError.

If kwargs contains an options keyword argument that is an instance of autobahn.wamp.types.CallOptions, this will provide specific options for the call to perform.

When the Caller and Dealer implementations support canceling of calls, the call may be canceled by canceling the returned Deferred/Future.

Parameters
  • procedure (unicode) – The URI of the remote procedure to be called, e.g. "com.myapp.hello".

  • args (list) – Any positional arguments for the call.

  • kwargs (dict) – Any keyword arguments for the call.

Returns

A Deferred/Future for the call result -

Return type

instance of twisted.internet.defer.Deferred / asyncio.Future

abstract define(exception, error=None)[source]

Defines an exception for a WAMP error in the context of this WAMP session.

Parameters
  • exception (A class that derives of Exception.) – The exception class to define an error mapping for.

  • error (str) – The URI (or URI pattern) the exception class should be mapped for. Iff the exception class is decorated, this must be None.

abstract disconnect()[source]

Close the underlying transport.

abstract get_payload_codec()[source]

Get the current payload codec (if any) for the session.

Payload codecs are used with WAMP payload transparency mode.

Returns

The current payload codec or None if no codec is active.

Return type

object implementing autobahn.wamp.interfaces.IPayloadCodec or None

abstract is_attached()[source]

Check if the session has currently joined a realm.

abstract is_connected()[source]

Check if the underlying transport is connected.

abstract join(realm, authmethods=None, authid=None, authrole=None, authextra=None, resumable=None, resume_session=None, resume_token=None)[source]

Attach the session to the given realm. A session is open as soon as it is attached to a realm.

abstract leave(reason=None, message=None)[source]

Actively close this WAMP session.

Parameters
  • reason (str) – An optional URI for the closing reason. If you want to permanently log out, this should be wamp.close.logout

  • message (str) – An optional (human readable) closing message, intended for logging purposes.

Returns

may return a Future/Deferred that fires when we’ve disconnected

abstract onChallenge(challenge)[source]

Callback fired when the peer demands authentication.

May return a Deferred/Future.

Parameters

challenge (Instance of autobahn.wamp.types.Challenge.) – The authentication challenge.

abstract onConnect()[source]

Callback fired when the transport this session will run over has been established.

abstract onDisconnect()[source]

Callback fired when underlying transport has been closed.

abstract onJoin(details)[source]

Callback fired when WAMP session has been established.

May return a Deferred/Future.

Parameters

details (Instance of autobahn.wamp.types.SessionDetails.) – Session information.

abstract onLeave(details)[source]

Callback fired when WAMP session has is closed

Parameters

details (Instance of autobahn.wamp.types.CloseDetails.) – Close information.

abstract onUserError(fail, msg)[source]

This is called when we try to fire a callback, but get an exception from user code – for example, a registered publish callback or a registered method. By default, this prints the current stack-trace and then error-message to stdout.

ApplicationSession-derived objects may override this to provide logging if they prefer. The Twisted implemention does this. (See autobahn.twisted.wamp.ApplicationSession)

Parameters
  • fail (instance implementing txaio.IFailedFuture) – The failure that occurred.

  • msg (str) – an informative message from the library. It is suggested you log this immediately after the exception.

abstract onWelcome(welcome_msg)[source]

Callback fired after the peer has successfully authenticated. If this returns anything other than None/False, the session is aborted and the return value is used as an error message.

May return a Deferred/Future.

Parameters

welcome_msg – The WELCOME message received from the server

Returns

None, or an error message

abstract publish(topic, *args, **kwargs)[source]

Publish an event to a topic.

If kwargs contains an options keyword argument that is an instance of autobahn.wamp.types.PublishOptions, this will provide specific options for the publish to perform.

Note

By default, publications are non-acknowledged and the publication can fail silently, e.g. because the session is not authorized to publish to the topic.

When publication acknowledgement is requested via options.acknowledge == True, this function returns a Deferred/Future:

  • If the publication succeeds the Deferred/Future will resolve to an object that implements autobahn.wamp.interfaces.IPublication.

  • If the publication fails the Deferred/Future will reject with an instance of autobahn.wamp.exception.ApplicationError.

Parameters
  • topic (unicode) – The URI of the topic to publish to, e.g. "com.myapp.mytopic1".

  • args (list) – Arbitrary application payload for the event (positional arguments).

  • kwargs (dict) – Arbitrary application payload for the event (keyword arguments).

Returns

Acknowledgement for acknowledge publications - otherwise nothing.

Return type

None or instance of twisted.internet.defer.Deferred / asyncio.Future

abstract register(endpoint, procedure=None, options=None, prefix=None, check_types=None)[source]

Register a procedure for remote calling.

When endpoint is a callable (function, method or object that implements __call__), then procedure must be provided and an instance of twisted.internet.defer.Deferred (when running on Twisted) or an instance of asyncio.Future (when running on asyncio) is returned.

  • If the registration succeeds the returned Deferred/Future will resolve to an object that implements autobahn.wamp.interfaces.IRegistration.

  • If the registration fails the returned Deferred/Future will reject with an instance of autobahn.wamp.exception.ApplicationError.

When endpoint is an object, then each of the object’s methods that is decorated with autobahn.wamp.register() is automatically registered and a (single) DeferredList or Future is returned that gathers all individual underlying Deferreds/Futures.

Parameters
  • endpoint (callable or object) – The endpoint called under the procedure.

  • procedure (unicode) – When endpoint is a callable, the URI (or URI pattern) of the procedure to register for. When endpoint is an object, the argument is ignored (and should be None).

  • options (instance of autobahn.wamp.types.RegisterOptions.) – Options for registering.

  • prefix (str) – if not None, this specifies a prefix to prepend to all URIs registered for this class. So if there was an @wamp.register(‘method_foo’) on a method and prefix=’com.something.’ then a method ‘com.something.method_foo’ would ultimately be registered.

  • check_types (bool) – Enable automatic type checking against (Python 3.5+) type hints specified on the endpoint callable. Types are checked at run-time on each invocation of the endpoint callable. When a type mismatch occurs, the error is forwarded to the callee code in onUserError override method of autobahn.wamp.protocol.ApplicationSession. An error of type autobahn.wamp.exception.TypeCheckError is also raised and returned to the caller (via the router).

Returns

A registration or a list of registrations (or errors)

Return type

instance(s) of twisted.internet.defer.Deferred / asyncio.Future

abstract set_payload_codec(payload_codec)[source]

Set a payload codec on the session. To remove a previously set payload codec, set the codec to None.

Payload codecs are used with WAMP payload transparency mode.

Parameters

payload_codec (object implementing autobahn.wamp.interfaces.IPayloadCodec or None) – The payload codec that should process application payload of the given encoding.

abstract subscribe(handler, topic=None, options=None, check_types=None)[source]

Subscribe to a topic for receiving events.

When handler is a callable (function, method or object that implements __call__), then topic must be provided and an instance of twisted.internet.defer.Deferred (when running on Twisted) or an instance of asyncio.Future (when running on asyncio) is returned.

  • If the subscription succeeds the Deferred/Future will resolve to an object that implements autobahn.wamp.interfaces.ISubscription.

  • If the subscription fails the Deferred/Future will reject with an instance of autobahn.wamp.exception.ApplicationError.

When handler is an object, then each of the object’s methods that is decorated with autobahn.wamp.subscribe() is automatically subscribed as event handlers, and a list of Deferreds/Futures is returned that each resolves or rejects as above.

Parameters
  • handler (callable or object) – The event handler to receive events.

  • topic (unicode) – When handler is a callable, the URI (or URI pattern) of the topic to subscribe to. When handler is an object, this value is ignored (and should be None).

  • options (An instance of autobahn.wamp.types.SubscribeOptions.) – Options for subscribing.

  • check_types (bool) – Enable automatic type checking against (Python 3.5+) type hints specified on the endpoint callable. Types are checked at run-time on each invocation of the endpoint callable. When a type mismatch occurs, the error is forwarded to the subscriber code in onUserError override method of autobahn.wamp.protocol.ApplicationSession.

Returns

A single Deferred/Future or a list of such objects

Return type

instance(s) of twisted.internet.defer.Deferred / asyncio.Future

class autobahn.wamp.interfaces.ITransport[source]

A WAMP transport is a bidirectional, full-duplex, reliable, ordered, message-based channel.

abstract abort()[source]

Abort the transport abruptly. The transport will be destroyed as fast as possible, and without playing nice to the peer. This should only be used in case of fatal errors, protocol violations or possible detected attacks.

abstract close()[source]

Close the transport regularly. The transport will perform any closing handshake if applicable. This should be used for any application initiated closing.

abstract get_channel_id()[source]

Return the unique channel ID of the underlying transport. This is used to mitigate credential forwarding man-in-the-middle attacks when running application level authentication (eg WAMP-cryptosign) which are decoupled from the underlying transport.

The channel ID is only available when running over TLS (either WAMP-WebSocket or WAMP-RawSocket). It is not available for non-TLS transports (plain TCP or Unix domain sockets). It is also not available for WAMP-over-HTTP/Longpoll. Further, it is currently unimplemented for asyncio (only works on Twisted).

The channel ID is computed as follows:

  • for a client, the SHA256 over the “TLS Finished” message sent by the client to the server is returned.

  • for a server, the SHA256 over the “TLS Finished” message the server expected the client to send

Note: this is similar to tls-unique as described in RFC5929, but instead of returning the raw “TLS Finished” message, it returns a SHA256 over such a message. The reason is that we use the channel ID mainly with WAMP-cryptosign, which is based on Ed25519, where keys are always 32 bytes. And having a channel ID which is always 32 bytes (independent of the TLS ciphers/hashfuns in use) allows use to easily XOR channel IDs with Ed25519 keys and WAMP-cryptosign challenges.

WARNING: For safe use of this (that is, for safely binding app level authentication to the underlying transport), you MUST use TLS, and you SHOULD deactivate both TLS session renegotiation and TLS session resumption.

References:

Returns

The channel ID (if available) of the underlying WAMP transport. The channel ID is a 32 bytes value.

Return type

binary or None

abstract isOpen()[source]

Check if the transport is open for messaging.

Returns

True, if the transport is open.

Return type

bool

abstract send(message)[source]

Send a WAMP message over the transport to the peer. If the transport is not open, this raises autobahn.wamp.exception.TransportLost. Returns a deferred/future when the message has been processed and more messages may be sent. When send() is called while a previous deferred/future has not yet fired, the send will fail immediately.

Parameters

message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message to send over the transport.

Returns

obj – A Deferred/Future

class autobahn.wamp.interfaces.ITransportHandler[source]
abstract onClose(wasClean)[source]

Callback fired when the transport has been closed.

Parameters

wasClean (bool) – Indicates if the transport has been closed regularly.

abstract onMessage(message)[source]

Callback fired when a WAMP message was received. May run asynchronously. The callback should return or fire the returned deferred/future when it’s done processing the message. In particular, an implementation of this callback must not access the message afterwards.

Parameters

message (object implementing autobahn.wamp.interfaces.IMessage) – The WAMP message received.

abstract onOpen(transport)[source]

Callback fired when transport is open. May run asynchronously. The transport is considered running and is_open() would return true, as soon as this callback has completed successfully.

Parameters

transport (object implementing autobahn.wamp.interfaces.ITransport) – The WAMP transport.

abstract property transport

When the transport this handler is attached to is currently open, this property can be read from. The property should be considered read-only. When the transport is gone, this property is set to None.

WAMP Types

class autobahn.wamp.types.Accept(realm=None, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None)[source]

Information to accept a HELLO.

Parameters
  • realm (str) – The realm the client is joined to.

  • authid (str) – The authentication ID the client is assigned, e.g. "joe" or "joe@example.com".

  • authrole (str) – The authentication role the client is assigned, e.g. "anonymous", "user" or "com.myapp.user".

  • authmethod (str) – The authentication method that was used to authenticate the client, e.g. "cookie" or "wampcra".

  • authprovider (str) – The authentication provider that was used to authenticate the client, e.g. "mozilla-persona".

  • authextra (dict) – Application-specific authextra to be forwarded to the client in WELCOME.details.authextra.

class autobahn.wamp.types.CallDetails(registration, progress=None, caller=None, caller_authid=None, caller_authrole=None, procedure=None, enc_algo=None, forward_for=None)[source]

Provides details on a call when an endpoint previously registered is being called and opted to receive call details.

Parameters
  • registration (instance of autobahn.wamp.request.Registration) – The (client side) registration object this invocation is delivered on.

  • progress (callable or None) – A callable that will receive progressive call results.

  • caller (int or None) – The WAMP session ID of the caller, if the latter is disclosed. Only filled when caller is disclosed.

  • caller_authid (str or None) – The WAMP authid of the original caller of this event. Only filled when caller is disclosed.

  • caller_authrole (str or None) – The WAMP authrole of the original caller of this event. Only filled when caller is disclosed.

  • procedure (str or None) – For pattern-based registrations, the actual procedure URI being called.

  • enc_algo (str or None) – Payload encryption algorithm that was in use (currently, either None or “cryptobox”).

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

class autobahn.wamp.types.CallOptions(on_progress=None, timeout=None, caller=None, caller_authid=None, caller_authrole=None, forward_for=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None, details=None)[source]

Used to provide options for calling with autobahn.wamp.interfaces.ICaller.call().

Parameters
  • on_progress (callable) – A callback that will be called when the remote endpoint called yields interim call progress results.

  • timeout (float) – Time in seconds after which the call should be automatically canceled.

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

message_attr()[source]

Returns options dict as sent within WAMP messages.

class autobahn.wamp.types.CallResult(*results, **kwresults)[source]

Wrapper for remote procedure call results that contain multiple positional return values or keyword-based return values.

Parameters
  • results (list) – The positional result values.

  • kwresults (dict) – The keyword result values.

class autobahn.wamp.types.Challenge(method, extra=None)[source]

Information to challenge the client upon HELLO.

Parameters
  • method (str) – The authentication method for the challenge (e.g. "wampcra").

  • extra (dict) – Any extra information for the authentication challenge. This is specific to the authentication method.

class autobahn.wamp.types.CloseDetails(reason=None, message=None)[source]

Provides details for a WAMP session upon close.

Parameters
  • reason (str) – The close reason (an URI, e.g. wamp.close.normal)

  • message (str) – Closing log message.

class autobahn.wamp.types.ComponentConfig(realm=None, extra=None, keyring=None, controller=None, shared=None, runner=None)[source]

WAMP application component configuration. An instance of this class is provided to the constructor of autobahn.wamp.protocol.ApplicationSession.

Parameters
  • realm (str) – The realm the session would like to join or None to let the router auto-decide the realm (if the router is configured and allowing to do so).

  • extra (arbitrary) – Optional user-supplied object with extra configuration. This can be any object you like, and is accessible in your ApplicationSession subclass via self.config.extra. dict is a good default choice. Important: if the component is to be hosted by Crossbar.io, the supplied value must be JSON serializable.

  • keyring (obj implementing IKeyRing or None) – A mapper from WAMP URIs to “from”/”to” Ed25519 keys. When using WAMP end-to-end encryption, application payload is encrypted using a symmetric message key, which in turn is encrypted using the “to” URI (topic being published to or procedure being called) public key and the “from” URI private key. In both cases, the key for the longest matching URI is used.

  • controller (instance of ApplicationSession or None) – A WAMP ApplicationSession instance that holds a session to a controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time.

  • shared (dict or None) – A dict object to exchange user information or hold user objects shared between components run under the same controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time. Use with caution, as using this feature can introduce coupling between components. A valid use case would be to hold a shared database connection pool.

  • runner (autobahn.twisted.wamp.ApplicationRunner) – Instance of ApplicationRunner when run under this.

class autobahn.wamp.types.Deny(reason='wamp.error.not_authorized', message=None)[source]

Information to deny a HELLO.

Parameters
  • reason (str) – The reason of denying the authentication (an URI, e.g. 'wamp.error.not_authorized')

  • message (str) – A human readable message (for logging purposes).

class autobahn.wamp.types.EncodedPayload(payload, enc_algo, enc_serializer=None, enc_key=None)[source]

Wrapper holding an encoded application payload when using WAMP payload transparency.

Parameters
  • payload (bytes) – The encoded application payload.

  • enc_algo (str) – The payload transparency algorithm identifier to check.

  • enc_serializer (str) – The payload transparency serializer identifier to check.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

class autobahn.wamp.types.EventDetails(subscription, publication, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, enc_algo=None, forward_for=None)[source]

Provides details on an event when calling an event handler previously registered.

Parameters
  • subscription (instance of autobahn.wamp.request.Subscription) – The (client side) subscription object on which this event is delivered.

  • publication (int) – The publication ID of the event (always present).

  • publisher (None or int) – The WAMP session ID of the original publisher of this event. Only filled when publisher is disclosed.

  • publisher_authid (str or None) – The WAMP authid of the original publisher of this event. Only filled when publisher is disclosed.

  • publisher_authrole (str or None) – The WAMP authrole of the original publisher of this event. Only filled when publisher is disclosed.

  • topic (str or None) – For pattern-based subscriptions, the actual topic URI being published to. Only filled for pattern-based subscriptions.

  • retained (bool or None) – Whether the message was retained by the broker on the topic, rather than just published.

  • enc_algo (str or None) – Payload encryption algorithm that was in use (currently, either None or 'cryptobox').

  • forward_for (list[dict]) – When this Event is forwarded for a client (or from an intermediary router).

class autobahn.wamp.types.HelloDetails(realm=None, authmethods=None, authid=None, authrole=None, authextra=None, session_roles=None, pending_session=None, resumable=None, resume_session=None, resume_token=None)[source]

Provides details of a WAMP session while still attaching.

Parameters
  • realm (str or None) – The realm the client wants to join.

  • authmethods (list of str or None) – The authentication methods the client is willing to perform.

  • authid (str or None) – The authid the client wants to authenticate as.

  • authrole (str or None) – The authrole the client wants to authenticate as.

  • authextra (arbitrary or None) – Any extra information the specific authentication method requires the client to send.

  • session_roles (dict or None) – The WAMP session roles and features by the connecting client.

  • pending_session (int or None) – The session ID the session will get once successfully attached.

  • resumable (bool or None) –

  • resume_session (int or None) – The session the client would like to resume.

  • resume_token (str or None) – The secure authorisation token to resume the session.

class autobahn.wamp.types.HelloReturn[source]

Base class for HELLO return information.

class autobahn.wamp.types.PublishOptions(acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None, forward_for=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]

Used to provide options for subscribing in autobahn.wamp.interfaces.IPublisher.publish().

Parameters
  • acknowledge (bool) – If True, acknowledge the publication with a success or error response.

  • exclude_me (bool or None) – If True, exclude the publisher from receiving the event, even if he is subscribed (and eligible).

  • exclude (int or list of int or None) – A single WAMP session ID or a list thereof to exclude from receiving this event.

  • exclude_authid (str or list of str or None) – A single WAMP authid or a list thereof to exclude from receiving this event.

  • exclude_authrole (list of str or None) – A single WAMP authrole or a list thereof to exclude from receiving this event.

  • eligible (int or list of int or None) – A single WAMP session ID or a list thereof eligible to receive this event.

  • eligible_authid (str or list of str or None) – A single WAMP authid or a list thereof eligible to receive this event.

  • eligible_authrole (str or list of str or None) – A single WAMP authrole or a list thereof eligible to receive this event.

  • retain (bool or None) – If True, request the broker retain this event.

  • forward_for (list[dict]) – When this Event is forwarded for a client (or from an intermediary router).

message_attr()[source]

Returns options dict as sent within WAMP messages.

class autobahn.wamp.types.RegisterOptions(match=None, invoke=None, concurrency=None, force_reregister=None, forward_for=None, details=None, details_arg=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]

Used to provide options for registering in autobahn.wamp.interfaces.ICallee.register().

Parameters
  • match – Type of matching to use on the URI (exact, prefix or wildcard)

  • invoke – Type of invoke mechanism to use (single, first, last, roundrobin, random)

  • concurrency – if used, the number of times a particular endpoint may be called concurrently (e.g. if this is 3, and there are already 3 calls in-progress a 4th call will receive an error)

  • details_arg (str) – When invoking the endpoint, provide call details in this keyword argument to the callable.

  • details (bool) – When invoking the endpoint, provide call details in a keyword parameter details.

  • details_arg – DEPCREATED (use “details” flag). When invoking the endpoint, provide call details in this keyword argument to the callable.

  • force_reregister (bool) – if True, any other session that has already registered this URI will be ‘kicked out’ and this session will become the one that’s registered (the previous session must have used force_reregister=True as well)

  • forward_for (list[dict]) – When this Register is forwarded over a router-to-router link, or via an intermediary router.

message_attr()[source]

Returns options dict as sent within WAMP messages.

class autobahn.wamp.types.SessionDetails(realm, session, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None, serializer=None, transport=None, resumed=None, resumable=None, resume_token=None)[source]

Provides details for a WAMP session upon open.

Parameters
  • realm (str) – The realm this WAMP session is attached to.

  • session (int) – WAMP session ID of this session.

  • resumed (bool or None) – Whether the session is a resumed one.

  • resumable (bool or None) – Whether this session can be resumed later.

  • resume_token (str or None) – The secure authorisation token to resume the session.

class autobahn.wamp.types.SessionIdent(session=None, authid=None, authrole=None)[source]

WAMP session identification information.

A WAMP session joined on a realm on a WAMP router is identified technically by its session ID (session) already.

The permissions the session has are tied to the WAMP authentication role (authrole).

The subject behind the session, eg the user or the application component is identified by the WAMP authentication ID (authid). One session is always authenticated under/as one specific authid, but a given authid might have zero, one or many sessions joined on a router at the same time.

Parameters
  • session (int) – WAMP session ID of the session.

  • authid (str) – The WAMP authid of the session.

  • authrole (str) – The WAMP authrole of the session.

static from_calldetails(call_details)[source]

Create a new session identification object from the caller information in the call details provided.

Parameters

call_details (autobahn.wamp.types.CallDetails) – Details of a WAMP call.

Returns

New session identification object.

Return type

autobahn.wamp.types.SessionIdent

static from_eventdetails(event_details)[source]

Create a new session identification object from the publisher information in the event details provided.

Parameters

event_details (autobahn.wamp.types.EventDetails) – Details of a WAMP event.

Returns

New session identification object.

Return type

autobahn.wamp.types.SessionIdent

class autobahn.wamp.types.SubscribeOptions(match=None, details=None, details_arg=None, forward_for=None, get_retained=None, correlation_id=None, correlation_uri=None, correlation_is_anchor=None, correlation_is_last=None)[source]

Used to provide options for subscribing in autobahn.wamp.interfaces.ISubscriber.subscribe().

Parameters
  • match (str) – The topic matching method to be used for the subscription.

  • details (bool) – When invoking the handler, provide event details in a keyword parameter details.

  • details_arg (str) – DEPCREATED (use “details” flag). When invoking the handler provide event details in this keyword argument to the callable.

  • get_retained (bool or None) – Whether the client wants the retained message we may have along with the subscription.

message_attr()[source]

Returns options dict as sent within WAMP messages.

class autobahn.wamp.request.CallRequest(request_id, procedure, on_reply, options)[source]

Object representing an outstanding request to call a procedure.

Parameters
  • request_id (int) – The WAMP request ID.

  • on_reply (Deferred/Future) – The Deferred/Future to be fired when the request returns.

  • options (dict) – WAMP call options that are in use for this call.

class autobahn.wamp.request.Endpoint(fn, obj=None, details_arg=None)[source]

Object representing an procedure endpoint attached to a registration.

Parameters
  • fn (callable) – The endpoint procedure to be called.

  • obj (obj or None) – The (optional) object upon which to call the function.

  • details_arg (str or None) – The keyword argument under which call details should be provided.

class autobahn.wamp.request.Handler(fn, obj=None, details_arg=None)[source]

Object representing an event handler attached to a subscription.

Parameters
  • fn (callable) – The event handler function to be called.

  • obj (obj or None) – The (optional) object upon which to call the function.

  • details_arg (str or None) – The keyword argument under which event details should be provided.

class autobahn.wamp.request.InvocationRequest(request_id, on_reply)[source]

Object representing an outstanding request to invoke an endpoint.

Parameters
  • request_id (int) – The WAMP request ID.

  • on_reply (Deferred/Future) – The Deferred/Future to be fired when the request returns.

class autobahn.wamp.request.Publication(publication_id, was_encrypted)[source]

Object representing a publication (feedback from publishing an event when doing an acknowledged publish).

Parameters
  • publication_id (int) – The publication ID of the published event.

  • was_encrypted (bool) – Flag indicating whether the app payload was encrypted.

class autobahn.wamp.request.PublishRequest(request_id, on_reply, was_encrypted)[source]

Object representing an outstanding request to publish (acknowledged) an event.

Parameters
  • request_id (int) – The WAMP request ID.

  • on_reply (Deferred/Future) – The Deferred/Future to be fired when the request returns.

  • was_encrypted (bool) – Flag indicating whether the app payload was encrypted.

class autobahn.wamp.request.RegisterRequest(request_id, on_reply, procedure, endpoint)[source]

Object representing an outstanding request to register a procedure.

class autobahn.wamp.request.Registration(session, registration_id, procedure, endpoint)[source]

Object representing a registration.

Parameters
  • id (int) – The registration ID.

  • active (bool) – Flag indicating whether this registration is active.

  • procedure (callable) – The procedure URI or URI pattern.

  • endpoint (callable) – The user callback.

unregister()[source]
class autobahn.wamp.request.SubscribeRequest(request_id, topic, on_reply, handler)[source]

Object representing an outstanding request to subscribe to a topic.

Parameters
  • request_id (int) – The WAMP request ID.

  • topic (unicode) – The topic URI being subscribed to.

  • on_reply (Deferred/Future) – The Deferred/Future to be fired when the request returns.

  • handler (callable) – WAMP call options that are in use for this call.

class autobahn.wamp.request.Subscription(subscription_id, topic, session, handler)[source]

Object representing a handler subscription.

Parameters
  • subscription_id (int) – The subscription ID.

  • topic (str) – The subscription URI or URI pattern.

  • session (instance of ApplicationSession) – The ApplicationSession this subscription is living on.

  • handler (callable) – The user event callback.

unsubscribe()[source]

Unsubscribe this subscription.

class autobahn.wamp.request.UnregisterRequest(request_id, on_reply, registration_id)[source]

Object representing an outstanding request to unregister a registration.

class autobahn.wamp.request.UnsubscribeRequest(request_id, on_reply, subscription_id)[source]

Object representing an outstanding request to unsubscribe a subscription.

WAMP Exceptions

exception autobahn.wamp.exception.ApplicationError(error, *args, **kwargs)[source]

Base class for all exceptions that can/may be handled at the application level.

Parameters

error (str) – The URI of the error that occurred, e.g. wamp.error.not_authorized.

AUTHENTICATION_FAILED = 'wamp.error.authentication_failed'

Something failed with the authentication itself, that is, authentication could not run to end.

AUTHORIZATION_FAILED = 'wamp.error.authorization_failed'

A Dealer or Broker could not determine if the Peer is authorized to perform a join, call, register, publish or subscribe, since the authorization operation itself failed. E.g. a custom authorizer did run into an error.

CANCELED = 'wamp.error.canceled'

A Dealer or Callee canceled a call previously issued (WAMP AP).

CLOSE_REALM = 'wamp.error.close_realm'

The Peer want to leave the realm - used as a GOODBYE reason.

ENC_DECRYPT_ERROR = 'wamp.error.encryption.decrypt_error'

WAMP-cryptobox application payload end-to-end encryption error.

ENC_NO_PAYLOAD_CODEC = 'wamp.error.no_payload_codec'

WAMP message in payload transparency mode received, but no codec set or codec did not decode the payload.

ENC_TRUSTED_URI_MISMATCH = 'wamp.error.encryption.trusted_uri_mismatch'

WAMP-cryptobox application payload end-to-end encryption error.

GOODBYE_AND_OUT = 'wamp.error.goodbye_and_out'

A Peer acknowledges ending of a session - used as a GOOBYE reply reason.

INVALID_ARGUMENT = 'wamp.error.invalid_argument'

A call failed, since the given argument types or values are not acceptable to the called procedure - in which case the Callee may throw this error. Or a Router performing payload validation checked the payload (args / kwargs) of a call, call result, call error or publish, and the payload did not conform.

INVALID_PAYLOAD = 'wamp.error.invalid_payload'

The application payload could not be serialized.

INVALID_URI = 'wamp.error.invalid_uri'

Peer provided an incorrect URI for a URI-based attribute of a WAMP message such as a realm, topic or procedure.

NOT_AUTHORIZED = 'wamp.error.not_authorized'

A call, register, publish or subscribe failed, since the session is not authorized to perform the operation.

NO_AUTH_METHOD = 'wamp.error.no_auth_method'

No authentication method the peer offered is available or active.

NO_ELIGIBLE_CALLEE = 'wamp.error.no_eligible_callee'

A Dealer could not perform a call, since a procedure with the given URI is registered, but Callee Black- and Whitelisting and/or Caller Exclusion lead to the exclusion of (any) Callee providing the procedure (WAMP AP).

NO_SUCH_PRINCIPAL = 'wamp.error.no_such_principal'

A Peer was authenticated for an authid that does not or longer exists.

NO_SUCH_PROCEDURE = 'wamp.error.no_such_procedure'

A Dealer could not perform a call, since not procedure is currently registered under the given URI.

NO_SUCH_REALM = 'wamp.error.no_such_realm'

Peer wanted to join a non-existing realm (and the Router did not allow to auto-create the realm).

NO_SUCH_REGISTRATION = 'wamp.error.no_such_registration'

A Dealer could not perform a unregister, since the given registration is not active.

NO_SUCH_ROLE = 'wamp.error.no_such_role'

A Peer was to be authenticated under a Role that does not (or no longer) exists on the Router. For example, the Peer was successfully authenticated, but the Role configured does not exists - hence there is some misconfiguration in the Router.

NO_SUCH_SESSION = 'wamp.error.no_such_session'

A router could not perform an operation, since a session ID specified was non-existant.

NO_SUCH_SUBSCRIPTION = 'wamp.error.no_such_subscription'

A Broker could not perform a unsubscribe, since the given subscription is not active.

PAYLOAD_SIZE_EXCEEDED = 'wamp.error.payload_size_exceeded'

The application payload could not be transported becuase the serialized/framed payload exceeds the transport limits.

PROCEDURE_ALREADY_EXISTS = 'wamp.error.procedure_already_exists'

A procedure could not be registered, since a procedure with the given URI is already registered.

PROCEDURE_EXISTS_INVOCATION_POLICY_CONFLICT = 'wamp.error.procedure_exists_with_different_invocation_policy'

A procedure could not be registered, since a procedure with the given URI is already registered, and the registration has a conflicting invocation policy.

SYSTEM_SHUTDOWN = 'wamp.error.system_shutdown'

The Peer is shutting down completely - used as a GOODBYE (or ABORT) reason.

TIMEOUT = 'wamp.error.timeout'

A pending (in-flight) call was timed out.

TYPE_CHECK_ERROR = 'wamp.error.type_check_error'

WAMP procedure called with wrong argument types or subscription published with wrong argument types.

error_message()[source]

Get the error message of this exception.

Returns

The error message.

Return type

str

exception autobahn.wamp.exception.Error[source]

Base class for all exceptions related to WAMP.

exception autobahn.wamp.exception.InvalidUri[source]

The URI for a topic, procedure or error is not a valid WAMP URI.

exception autobahn.wamp.exception.NotAuthorized[source]

Not authorized to perform the respective action.

exception autobahn.wamp.exception.ProtocolError[source]

Exception raised when WAMP protocol was violated. Protocol errors are fatal and are handled by the WAMP implementation. They are not supposed to be handled at the application level.

exception autobahn.wamp.exception.SerializationError[source]

Exception raised when the WAMP serializer could not serialize the application payload (args or kwargs for CALL, PUBLISH, etc).

exception autobahn.wamp.exception.SessionNotReady[source]

The application tried to perform a WAMP interaction, but the session is not yet fully established.

exception autobahn.wamp.exception.TransportLost[source]

Exception raised when the transport underlying the WAMP session was lost or is not connected.

WAMP Authentication and Encryption

class autobahn.wamp.cryptobox.EncodedPayload(payload, enc_algo, enc_serializer=None, enc_key=None)[source]

Wrapper holding an encoded application payload when using WAMP payload transparency.

Parameters
  • payload (bytes) – The encoded application payload.

  • enc_algo (str) – The payload transparency algorithm identifier to check.

  • enc_serializer (str) – The payload transparency serializer identifier to check.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

WAMP Serializer

class autobahn.wamp.serializer.JsonSerializer(batched=False)[source]

Ctor.

Parameters

batched (bool) – Flag to control whether to put this serialized into batched mode.

MIME_TYPE = 'application/json'

MIME type announced in HTTP request/response headers when running WAMP-over-Longpoll HTTP fallback.

RAWSOCKET_SERIALIZER_ID = 1

ID used in lower four bits of second octet in RawSocket opening handshake identify the serializer with WAMP-over-RawSocket.

SERIALIZER_ID = 'json'

ID used as part of the WebSocket subprotocol name to identify the serializer with WAMP-over-WebSocket.

class autobahn.wamp.serializer.Serializer(serializer)[source]

Base class for WAMP serializers. A WAMP serializer is the core glue between parsed WAMP message objects and the bytes on wire (the transport).

Parameters

serializer (An object that implements autobahn.interfaces.IObjectSerializer.) – The object serializer to use for WAMP wire-level serialization.

MESSAGE_TYPE_MAP = {1: <class 'autobahn.wamp.message.Hello'>, 2: <class 'autobahn.wamp.message.Welcome'>, 3: <class 'autobahn.wamp.message.Abort'>, 4: <class 'autobahn.wamp.message.Challenge'>, 5: <class 'autobahn.wamp.message.Authenticate'>, 6: <class 'autobahn.wamp.message.Goodbye'>, 8: <class 'autobahn.wamp.message.Error'>, 16: <class 'autobahn.wamp.message.Publish'>, 17: <class 'autobahn.wamp.message.Published'>, 32: <class 'autobahn.wamp.message.Subscribe'>, 33: <class 'autobahn.wamp.message.Subscribed'>, 34: <class 'autobahn.wamp.message.Unsubscribe'>, 35: <class 'autobahn.wamp.message.Unsubscribed'>, 36: <class 'autobahn.wamp.message.Event'>, 48: <class 'autobahn.wamp.message.Call'>, 49: <class 'autobahn.wamp.message.Cancel'>, 50: <class 'autobahn.wamp.message.Result'>, 64: <class 'autobahn.wamp.message.Register'>, 65: <class 'autobahn.wamp.message.Registered'>, 66: <class 'autobahn.wamp.message.Unregister'>, 67: <class 'autobahn.wamp.message.Unregistered'>, 68: <class 'autobahn.wamp.message.Invocation'>, 69: <class 'autobahn.wamp.message.Interrupt'>, 70: <class 'autobahn.wamp.message.Yield'>}

Mapping of WAMP message type codes to WAMP message classes.

RATED_MESSAGE_SIZE = 512

Serialized WAMP message payload size per rated WAMP message.

serialize(msg)[source]

Implements autobahn.wamp.interfaces.ISerializer.serialize()

set_stats_autoreset(rated_messages, duration, callback, reset_now=False)[source]

Configure a user callback invoked when accumulated stats hit specified threshold. When the specified number of rated messages have been processed or the specified duration has passed, statistics are automatically reset, and the last statistics is provided to the user callback.

Parameters
  • rated_messages (int) – Number of rated messages that should trigger an auto-reset.

  • duration (int) – Duration in ns that when passed will trigger an auto-reset.

  • callback (callable) – User callback to be invoked when statistics are auto-reset. The function will be invoked with a single positional argument: the accumulated statistics before the reset.

stats(reset=True, details=False)[source]

Get (and reset) serializer statistics.

Parameters
  • reset (bool) – If True, reset the serializer statistics.

  • details (bool) – If True, return detailed statistics split up by serialization/unserialization.

Returns

Serializer statistics, eg:

{
    "timestamp": 1574156576688704693,
    "duration": 34000000000,
    "bytes": 0,
    "messages": 0,
    "rated_messages": 0
}

Return type

dict

stats_bytes()[source]

Get serializer statistics: bytes (serialized + unserialized).

Returns

Number of bytes.

Return type

int

stats_messages()[source]

Get serializer statistics: messages (serialized + unserialized).

Returns

Number of messages.

Return type

int

stats_rated_messages()[source]

Get serializer statistics: rated messages (serialized + unserialized).

Returns

Number of rated messages.

Return type

int

stats_reset()[source]

Get serializer statistics: timestamp when statistics were last reset.

Returns

Last reset time of statistics (UTC, ns since Unix epoch)

Return type

int

unserialize(payload, isBinary=None)[source]

Implements autobahn.wamp.interfaces.ISerializer.unserialize()

WAMP Messages

class autobahn.wamp.message.Abort(reason, message=None)[source]

A WAMP ABORT message.

Format: [ABORT, Details|dict, Reason|uri]

Parameters
  • reason (str) – WAMP or application error URI for aborting reason.

  • message (str or None) – Optional human-readable closing message, e.g. for logging purposes.

MESSAGE_TYPE = 3

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Authenticate(signature, extra=None)[source]

A WAMP AUTHENTICATE message.

Format: [AUTHENTICATE, Signature|string, Extra|dict]

Parameters
  • signature (str) – The signature for the authentication challenge.

  • extra (dict or None) – Authentication method specific information.

MESSAGE_TYPE = 5

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Call(request, procedure, args=None, kwargs=None, payload=None, timeout=None, receive_progress=None, enc_algo=None, enc_key=None, enc_serializer=None, caller=None, caller_authid=None, caller_authrole=None, forward_for=None)[source]

A WAMP CALL message.

Formats:

  • [CALL, Request|id, Options|dict, Procedure|uri]

  • [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list]

  • [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list, ArgumentsKw|dict]

  • [CALL, Request|id, Options|dict, Procedure|uri, Payload|binary]

Parameters
  • request (int) – The WAMP request ID of this request.

  • procedure (str) – The WAMP or application URI of the procedure which should be called.

  • args (list or tuple or None) – Positional values for application-defined call arguments. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined call arguments. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • timeout (int or None) – If present, let the callee automatically cancel the call after this ms.

  • receive_progress (bool or None) – If True, indicates that the caller wants to receive progressive call results.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • caller (None or int) – The WAMP session ID of the caller. Only filled if caller is disclosed.

  • caller_authid (None or unicode) – The WAMP authid of the caller. Only filled if caller is disclosed.

  • caller_authrole (None or unicode) – The WAMP authrole of the caller. Only filled if caller is disclosed.

  • forward_for (list[dict]) – When this Publish is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 48

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Cancel(request, mode=None, forward_for=None)[source]

A WAMP CANCEL message.

Format: [CANCEL, CALL.Request|id, Options|dict]

See: https://wamp-proto.org/static/rfc/draft-oberstet-hybi-crossbar-wamp.html#rfc.section.14.3.4

Parameters
  • request (int) – The WAMP request ID of the original CALL to cancel.

  • mode (str or None) – Specifies how to cancel the call ("skip", "killnowait" or "kill").

  • forward_for (list[dict]) – When this Cancel is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 49

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Challenge(method, extra=None)[source]

A WAMP CHALLENGE message.

Format: [CHALLENGE, Method|string, Extra|dict]

Parameters
  • method (str) – The authentication method.

  • extra (dict or None) – Authentication method specific information.

MESSAGE_TYPE = 4

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Error(request_type, request, error, args=None, kwargs=None, payload=None, enc_algo=None, enc_key=None, enc_serializer=None, callee=None, callee_authid=None, callee_authrole=None, forward_for=None)[source]

A WAMP ERROR message.

Formats:

  • [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri]

  • [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list]

  • [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict]

  • [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Payload|binary]

Parameters
  • request_type (int) – The WAMP message type code for the original request.

  • request (int) – The WAMP request ID of the original request (Call, Subscribe, …) this error occurred for.

  • error (str) – The WAMP or application error URI for the error that occurred.

  • args (list or None) – Positional values for application-defined exception. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined exception. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • callee (None or int) – The WAMP session ID of the effective callee that responded with the error. Only filled if callee is disclosed.

  • callee_authid (None or unicode) – The WAMP authid of the responding callee. Only filled if callee is disclosed.

  • callee_authrole (None or unicode) – The WAMP authrole of the responding callee. Only filled if callee is disclosed.

  • forward_for (list[dict]) – When this Error is forwarded for a client/callee (or from an intermediary router).

MESSAGE_TYPE = 8

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Event(subscription=None, publication=None, args=None, kwargs=None, payload=None, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, x_acknowledged_delivery=None, enc_algo=None, enc_key=None, enc_serializer=None, forward_for=None, from_fbs=None)[source]

A WAMP EVENT message.

Formats:

  • [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict]

  • [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list]

  • [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentsKw|dict]

  • [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Payload|binary]

Parameters
  • subscription (int) – The subscription ID this event is dispatched under.

  • publication (int) – The publication ID of the dispatched event.

  • args (list or tuple or None) – Positional values for application-defined exception. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined exception. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • publisher (None or int) – The WAMP session ID of the publisher. Only filled if publisher is disclosed.

  • publisher_authid (None or unicode) – The WAMP authid of the publisher. Only filled if publisher is disclosed.

  • publisher_authrole (None or unicode) – The WAMP authrole of the publisher. Only filled if publisher is disclosed.

  • topic (str or None) – For pattern-based subscriptions, the event MUST contain the actual topic published to.

  • retained (bool or None) – Whether the message was retained by the broker on the topic, rather than just published.

  • x_acknowledged_delivery (bool or None) – Whether this Event should be acknowledged.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • forward_for (list[dict]) – When this Event is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 36

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Goodbye(reason='wamp.close.normal', message=None, resumable=None)[source]

A WAMP GOODBYE message.

Format: [GOODBYE, Details|dict, Reason|uri]

Parameters
  • reason (str) – Optional WAMP or application error URI for closing reason.

  • message (str or None) – Optional human-readable closing message, e.g. for logging purposes.

  • resumable (bool or None) – From the server: Whether the session is able to be resumed (true) or destroyed (false). From the client: Whether it should be resumable (true) or destroyed (false).

DEFAULT_REASON = 'wamp.close.normal'

Default WAMP closing reason.

MESSAGE_TYPE = 6

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Hello(realm, roles, authmethods=None, authid=None, authrole=None, authextra=None, resumable=None, resume_session=None, resume_token=None)[source]

A WAMP HELLO message.

Format: [HELLO, Realm|uri, Details|dict]

Parameters
  • realm (str) – The URI of the WAMP realm to join.

  • roles (dict of autobahn.wamp.role.RoleFeatures) – The WAMP session roles and features to announce.

  • authmethods (list of str or None) – The authentication methods to announce.

  • authid (str or None) – The authentication ID to announce.

  • authrole (str or None) – The authentication role to announce.

  • authextra (dict or None) – Application-specific “extra data” to be forwarded to the client.

  • resumable (bool or None) – Whether the client wants this to be a session that can be later resumed.

  • resume_session (int or None) – The session the client would like to resume.

  • resume_token (str or None) – The secure authorisation token to resume the session.

MESSAGE_TYPE = 1

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Interrupt(request, mode=None, reason=None, forward_for=None)[source]

A WAMP INTERRUPT message.

Format: [INTERRUPT, INVOCATION.Request|id, Options|dict]

See: https://wamp-proto.org/static/rfc/draft-oberstet-hybi-crossbar-wamp.html#rfc.section.14.3.4

Parameters
  • request (int) – The WAMP request ID of the original INVOCATION to interrupt.

  • mode (str or None) – Specifies how to interrupt the invocation ("killnowait" or "kill"). With "kill", the router will wait for the callee to return an ERROR before proceeding (sending back an ERROR to the original caller). With "killnowait" the router will immediately proceed (on the caller side returning an ERROR) - but still expects the callee to send an ERROR to conclude the message exchange for the inflight call.

  • reason (str or None.) – The reason (an URI) for the invocation interrupt, eg actively triggered by the caller ("wamp.error.canceled" - ApplicationError.CANCELED) or passively because of timeout ("wamp.error.timeout" - ApplicationError.TIMEOUT).

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 69

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Invocation(request, registration, args=None, kwargs=None, payload=None, timeout=None, receive_progress=None, caller=None, caller_authid=None, caller_authrole=None, procedure=None, enc_algo=None, enc_key=None, enc_serializer=None, forward_for=None)[source]

A WAMP INVOCATION message.

Formats:

  • [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict]

  • [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list]

  • [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict]

  • [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, Payload|binary]

Parameters
  • request (int) – The WAMP request ID of this request.

  • registration (int) – The registration ID of the endpoint to be invoked.

  • args (list or tuple or None) – Positional values for application-defined event payload. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined event payload. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • timeout (int or None) – If present, let the callee automatically cancels the invocation after this ms.

  • receive_progress (bool or None) – Indicates if the callee should produce progressive results.

  • caller (None or int) – The WAMP session ID of the caller. Only filled if caller is disclosed.

  • caller_authid (None or unicode) – The WAMP authid of the caller. Only filled if caller is disclosed.

  • caller_authrole (None or unicode) – The WAMP authrole of the caller. Only filled if caller is disclosed.

  • procedure (str or None) – For pattern-based registrations, the invocation MUST include the actual procedure being called.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 68

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Message(from_fbs=None)[source]

WAMP message base class.

Note

This is not supposed to be instantiated, but subclassed only.

MESSAGE_TYPE = None

WAMP message type code.

static parse(wmsg)[source]

Factory method that parses a unserialized raw message (as returned byte autobahn.interfaces.ISerializer.unserialize()) into an instance of this class.

Returns

An instance of this class.

Return type

obj

serialize(serializer)[source]

Serialize this object into a wire level bytes representation and cache the resulting bytes. If the cache already contains an entry for the given serializer, return the cached representation directly.

Parameters

serializer (An instance that implements autobahn.interfaces.ISerializer) – The wire level serializer to use.

Returns

The serialized bytes.

Return type

bytes

uncache()[source]

Resets the serialization cache.

class autobahn.wamp.message.Publish(request=None, topic=None, args=None, kwargs=None, payload=None, acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None, enc_algo=None, enc_key=None, enc_serializer=None, forward_for=None, from_fbs=None)[source]

A WAMP PUBLISH message.

Formats:

  • [PUBLISH, Request|id, Options|dict, Topic|uri]

  • [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list]

  • [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list, ArgumentsKw|dict]

  • [PUBLISH, Request|id, Options|dict, Topic|uri, Payload|binary]

Parameters
  • request (int) – The WAMP request ID of this request.

  • topic (str) – The WAMP or application URI of the PubSub topic the event should be published to.

  • args (list or tuple or None) – Positional values for application-defined event payload. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined event payload. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • acknowledge (bool or None) – If True, acknowledge the publication with a success or error response.

  • exclude_me (bool or None) – If True, exclude the publisher from receiving the event, even if he is subscribed (and eligible).

  • exclude (list of int or None) – List of WAMP session IDs to exclude from receiving this event.

  • exclude_authid (list of str or None) – List of WAMP authids to exclude from receiving this event.

  • exclude_authrole (list of str or None) – List of WAMP authroles to exclude from receiving this event.

  • eligible (list of int or None) – List of WAMP session IDs eligible to receive this event.

  • eligible_authid (list of str or None) – List of WAMP authids eligible to receive this event.

  • eligible_authrole (list of str or None) – List of WAMP authroles eligible to receive this event.

  • retain (bool or None) – If True, request the broker retain this event.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 16

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Published(request, publication)[source]

A WAMP PUBLISHED message.

Format: [PUBLISHED, PUBLISH.Request|id, Publication|id]

Parameters
  • request (int) – The request ID of the original PUBLISH request.

  • publication (int) – The publication ID for the published event.

MESSAGE_TYPE = 17

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Register(request, procedure, match=None, invoke=None, concurrency=None, force_reregister=None, forward_for=None)[source]

A WAMP REGISTER message.

Format: [REGISTER, Request|id, Options|dict, Procedure|uri]

Parameters
  • request (int) – The WAMP request ID of this request.

  • procedure (str) – The WAMP or application URI of the RPC endpoint provided.

  • match (str) – The procedure matching policy to be used for the registration.

  • invoke (str) – The procedure invocation policy to be used for the registration.

  • concurrency (int) – The (maximum) concurrency to be used for the registration.

  • forward_for (list[dict]) – When this Register is forwarded over a router-to-router link, or via an intermediary router.

MESSAGE_TYPE = 64

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Registered(request, registration)[source]

A WAMP REGISTERED message.

Format: [REGISTERED, REGISTER.Request|id, Registration|id]

Parameters
  • request (int) – The request ID of the original REGISTER request.

  • registration (int) – The registration ID for the registered procedure (or procedure pattern).

MESSAGE_TYPE = 65

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Result(request, args=None, kwargs=None, payload=None, progress=None, enc_algo=None, enc_key=None, enc_serializer=None, callee=None, callee_authid=None, callee_authrole=None, forward_for=None)[source]

A WAMP RESULT message.

Formats:

  • [RESULT, CALL.Request|id, Details|dict]

  • [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list]

  • [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list, YIELD.ArgumentsKw|dict]

  • [RESULT, CALL.Request|id, Details|dict, Payload|binary]

Parameters
  • request (int) – The request ID of the original CALL request.

  • args (list or tuple or None) – Positional values for application-defined event payload. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined event payload. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • progress (bool or None) – If True, this result is a progressive call result, and subsequent results (or a final error) will follow.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • callee (None or int) – The WAMP session ID of the effective callee that responded with the result. Only filled if callee is disclosed.

  • callee_authid (None or unicode) – The WAMP authid of the responding callee. Only filled if callee is disclosed.

  • callee_authrole (None or unicode) – The WAMP authrole of the responding callee. Only filled if callee is disclosed.

  • forward_for (list[dict]) – When this Result is forwarded for a client/callee (or from an intermediary router).

MESSAGE_TYPE = 50

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Subscribe(request, topic, match=None, get_retained=None, forward_for=None)[source]

A WAMP SUBSCRIBE message.

Format: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]

Parameters
  • request (int) – The WAMP request ID of this request.

  • topic (str) – The WAMP or application URI of the PubSub topic to subscribe to.

  • match (str) – The topic matching method to be used for the subscription.

  • get_retained (bool or None) – Whether the client wants the retained message we may have along with the subscription.

  • forward_for (list[dict]) – When this Subscribe is forwarded over a router-to-router link, or via an intermediary router.

MESSAGE_TYPE = 32

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Subscribed(request, subscription)[source]

A WAMP SUBSCRIBED message.

Format: [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]

Parameters
  • request (int) – The request ID of the original SUBSCRIBE request.

  • subscription (int) – The subscription ID for the subscribed topic (or topic pattern).

MESSAGE_TYPE = 33

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Unregister(request, registration, forward_for=None)[source]

A WAMP UNREGISTER message.

Formats:

  • [UNREGISTER, Request|id, REGISTERED.Registration|id]

  • [UNREGISTER, Request|id, REGISTERED.Registration|id, Options|dict]

Parameters
  • request (int) – The WAMP request ID of this request.

  • registration (int) – The registration ID for the registration to unregister.

  • forward_for (list[dict]) – When this Unregister is forwarded over a router-to-router link, or via an intermediary router.

MESSAGE_TYPE = 66

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Unregistered(request, registration=None, reason=None)[source]

A WAMP UNREGISTERED message.

Formats:

  • [UNREGISTERED, UNREGISTER.Request|id]

  • [UNREGISTERED, UNREGISTER.Request|id, Details|dict]

Parameters
  • request (int) – The request ID of the original UNREGISTER request.

  • registration (int or None) – If unregister was actively triggered by router, the ID of the registration revoked.

  • reason (str or None.) – The reason (an URI) for revocation.

MESSAGE_TYPE = 67

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Unsubscribe(request, subscription, forward_for=None)[source]

A WAMP UNSUBSCRIBE message.

Formats:

  • [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]

  • [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id, Options|dict]

Parameters
  • request (int) – The WAMP request ID of this request.

  • subscription (int) – The subscription ID for the subscription to unsubscribe from.

  • forward_for (list[dict]) – When this Unsubscribe is forwarded over a router-to-router link, or via an intermediary router.

MESSAGE_TYPE = 34

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Unsubscribed(request, subscription=None, reason=None)[source]

A WAMP UNSUBSCRIBED message.

Formats:

  • [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]

  • [UNSUBSCRIBED, UNSUBSCRIBE.Request|id, Details|dict]

Parameters
  • request (int) – The request ID of the original UNSUBSCRIBE request or 0 is router triggered unsubscribe (“router revocation signaling”).

  • subscription (int or None) – If unsubscribe was actively triggered by router, the ID of the subscription revoked.

  • reason (str or None.) – The reason (an URI) for an active (router initiated) revocation.

MESSAGE_TYPE = 35

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Welcome(session, roles, realm=None, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None, resumed=None, resumable=None, resume_token=None, custom=None)[source]

A WAMP WELCOME message.

Format: [WELCOME, Session|id, Details|dict]

Parameters
  • session (int) – The WAMP session ID the other peer is assigned.

  • roles (dict of autobahn.wamp.role.RoleFeatures) – The WAMP roles to announce.

  • realm (str or None) – The effective realm the session is joined on.

  • authid (str or None) – The authentication ID assigned.

  • authrole (str or None) – The authentication role assigned.

  • authmethod (str or None) – The authentication method in use.

  • authprovider (str or None) – The authentication provided in use.

  • authextra (arbitrary or None) – Application-specific “extra data” to be forwarded to the client.

  • resumed (bool or None) – Whether the session is a resumed one.

  • resumable (bool or None) – Whether this session can be resumed later.

  • resume_token (str or None) – The secure authorisation token to resume the session.

  • custom (dict or None) – Implementation-specific “custom attributes” (x_my_impl_attribute) to be set.

MESSAGE_TYPE = 2

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

class autobahn.wamp.message.Yield(request, args=None, kwargs=None, payload=None, progress=None, enc_algo=None, enc_key=None, enc_serializer=None, callee=None, callee_authid=None, callee_authrole=None, forward_for=None)[source]

A WAMP YIELD message.

Formats:

  • [YIELD, INVOCATION.Request|id, Options|dict]

  • [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list]

  • [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list, ArgumentsKw|dict]

  • [YIELD, INVOCATION.Request|id, Options|dict, Payload|binary]

Parameters
  • request (int) – The WAMP request ID of the original call.

  • args (list or tuple or None) – Positional values for application-defined event payload. Must be serializable using any serializers in use.

  • kwargs (dict or None) – Keyword values for application-defined event payload. Must be serializable using any serializers in use.

  • payload (bytes or None) – Alternative, transparent payload. If given, args and kwargs must be left unset.

  • progress (bool or None) – If True, this result is a progressive invocation result, and subsequent results (or a final error) will follow.

  • enc_algo (str or None) – If using payload transparency, the encoding algorithm that was used to encode the payload.

  • enc_key (str or None) – If using payload transparency with an encryption algorithm, the payload encryption key.

  • enc_serializer (str or None) – If using payload transparency, the payload object serializer that was used encoding the payload.

  • callee (None or int) – The WAMP session ID of the effective callee that responded with the error. Only filled if callee is disclosed.

  • callee_authid (None or unicode) – The WAMP authid of the responding callee. Only filled if callee is disclosed.

  • callee_authrole (None or unicode) – The WAMP authrole of the responding callee. Only filled if callee is disclosed.

  • forward_for (list[dict]) – When this Call is forwarded for a client (or from an intermediary router).

MESSAGE_TYPE = 70

The WAMP message code for this type of message.

marshal()[source]

Marshal this object into a raw message for subsequent serialization to bytes.

Returns

The serialized raw message.

Return type

list

static parse(wmsg)[source]

Verifies and parses an unserialized raw message into an actual WAMP message instance.

Parameters

wmsg (list) – The unserialized raw message.

Returns

An instance of this class.

autobahn.wamp.message.check_or_raise_id(value, message='WAMP message invalid')[source]

Check a value for being a valid WAMP ID.

If the value is not a valid WAMP ID, raises autobahn.wamp.exception.ProtocolError. Otherwise return the value.

Parameters
  • value (int) – The value to check.

  • message (str) – Prefix for message in exception raised when value is invalid.

Returns

The ID value (if valid).

Return type

int

Raises

instance of autobahn.wamp.exception.ProtocolError

autobahn.wamp.message.check_or_raise_uri(value, message='WAMP message invalid', strict=False, allow_empty_components=False, allow_last_empty=False, allow_none=False)[source]

Check a value for being a valid WAMP URI.

If the value is not a valid WAMP URI is invalid, raises autobahn.wamp.exception.ProtocolError. Otherwise return the value.

Parameters
  • value (str or None) – The value to check.

  • message (str) – Prefix for message in exception raised when value is invalid.

  • strict (bool) – If True, do a strict check on the URI (the WAMP spec SHOULD behavior).

  • allow_empty_components (bool) – If True, allow empty URI components (for pattern based subscriptions and registrations).

  • allow_none (bool) – If True, allow None for URIs.

Returns

The URI value (if valid).

Return type

str

Raises

instance of autobahn.wamp.exception.ProtocolError

autobahn.wamp.message.is_valid_enc_algo(enc_algo)[source]

For WAMP payload transparency mode, check if the provided enc_algo identifier in the WAMP message is a valid one.

Currently defined standard identifiers are:

  • "cryptobox"

  • "mqtt"

  • "xbr"

Users can select arbitrary identifiers too, but these MUST start with "x_".

Parameters

enc_algo (str) – The payload transparency algorithm identifier to check.

Returns

Returns True if and only if the payload transparency algorithm identifier is valid.

Return type

bool

autobahn.wamp.message.is_valid_enc_serializer(enc_serializer)[source]

For WAMP payload transparency mode, check if the provided enc_serializer identifier in the WAMP message is a valid one.

Currently, the only standard defined identifier are

  • "json"

  • "msgpack"

  • "cbor"

  • "ubjson"

  • "flatbuffers"

Users can select arbitrary identifiers too, but these MUST start with "x_".

Parameters

enc_serializer (str) – The payload transparency serializer identifier to check.

Returns

Returns True if and only if the payload transparency serializer identifier is valid.

Return type

bool