Module autobahn.wamp

WAMP Interfaces

class autobahn.wamp.interfaces.IAuthenticator[source]

Experimental authentication API.

abstract on_challenge(session: ISession, challenge: Challenge)[source]

Formulate a challenge response for the given session and Challenge instance. This is sent to the server in the AUTHENTICATE message.

abstract on_welcome(authextra: Optional[Dict[str, Any]]) Optional[str][source]

This hook is called when the onWelcome/on_welcome hook is invoked in the protocol, with the ‘authextra’ dict extracted from the Welcome message. Usually this is used to verify the final message from the server (e.g. for mutual authentication).

Returns

None if the session is successful or an error-message

class autobahn.wamp.interfaces.ICryptosignKey[source]

Interface to a WAMP-Cryptosign client authentication (or server verification) key.

abstract sign_challenge(challenge: Challenge, channel_id: Optional[bytes] = None, channel_id_type: Optional[str] = None) bytes[source]

Sign the data from the given WAMP challenge message, and the optional TLS channel ID using this key and return a valid signature that can be used in a WAMP-cryptosign authentication handshake.

Parameters
  • challenge – The WAMP challenge message as sent or received during the WAMP-cryptosign authentication handshake. This can be used by WAMP clients to compute the signature returned in the handshake, or by WAMP routers to verify the signature returned by clients, during WAMP-cryptosign client authentication.

  • channel_id – Optional TLS channel ID. Using this binds the WAMP session authentication to the underlying TLS channel, and thus prevents authentication-forwarding attacks.

  • channel_id_type – Optional TLS channel ID type, e.g. "tls-unique".

Returns

The signature, that is a future object that resolves to bytes.

abstract verify_challenge(challenge: Challenge, signature: bytes, channel_id: Optional[bytes] = None, channel_id_type: Optional[str] = None) bool[source]

Verify the data from the given WAMP challenge message, and the optional TLS channel ID to be signed by this key.

Parameters
  • challenge – The WAMP challenge message as sent or received during the WAMP-cryptosign authentication handshake. This can be used by WAMP clients to compute the signature returned within the handshake, or by WAMP routers to verify the signature returned by clients, during WAMP-cryptosign client authentication.

  • signature – The signature to verify.

  • channel_id – Optional TLS channel ID. Using this binds the WAMP session authentication to the underlying TLS channel, and thus prevents authentication-forwarding attacks.

  • channel_id_type – Optional TLS channel ID type, e.g. "tls-unique".

Returns

Returns True if the signature over the data matches this key.

class autobahn.wamp.interfaces.IEthereumKey[source]

Interface to an Ethereum signing (or transaction verification) key, used for WAMP-XBR transaction signing (or verification).

abstract address(binary: bool = False) Union[str, bytes][source]

Returns the Ethereum (public) address of the key (which is derived from the public key).

Parameters

binary – Return address as 160 bits (20 bytes) binary instead of the 0x prefixed hex, check-summed address as a string.

Returns

The address in hex or byte encoding.

abstract sign_typed_data(data: Dict[str, Any]) bytes[source]

Sign the given typed data according to EIP712 and create an Ethereum signature.

Parameters

data – The data to be signed. This must follow EIP712.

Returns

The signature, that is a future object that resolves to bytes.

abstract verify_typed_data(data: Dict[str, Any], signature: bytes, signer_address: Union[str, bytes]) bool[source]

Verify the given typed data according to EIP712 to be signed by this key.

Parameters
  • data – The data to be signed. This must follow EIP712.

  • signature – The signature to be verified.

  • signer_address – Address against which the signature is verified.

Returns

Returns True if the signature over the data matches this key.

class autobahn.wamp.interfaces.IKey[source]

Interface to an asymmetric verification key, e.g. a WAMP-Cryptosign client or server authentication public key (with Ed25519), or a WAMP-XBR data transaction signature public key or address (with Ethereum).

The key implementation can use various methods, such as a key read from a file, database table or a key residing in a hardware device.

abstract can_sign() bool[source]

Check if the key can be used to sign and create new signatures, or only to verify signatures.

Returns

True, if the key can be used for signing.

abstract property key_no: Optional[int]

When this key is hosted by a security module, return an identifier to refer to this key within the security module. If the key is freestanding (exists of its own outside any security module or key store), return None.

Returns

The identifier of this key within the security module if this key is hosted.

abstract property key_type: str

Type of key and signature scheme, currently one of:

  • ed25519: Ed25519, that is EdDSA signing algo with Curve25519 elliptic curve and SHA-512 hash,

    used with WAMP-cryptosign session authentication

  • eth: Ethereum, that is ECDSA signing algo, secp256k1 elliptic curve and Keccak-256 hash,

    used with WAMP-XBR data and transaction signatures

Returns

Key type, one of ed25519 or eth.

abstract public_key(binary: bool = False) Union[str, bytes][source]

Returns the public key part of a signing key or the (public) verification key.

Parameters

binary – If the return type should be binary instead of hex

Returns

The public key in hex or byte encoding.

abstract recover(data: bytes, signature: bytes) bytes[source]

Recover the signer from the data signed, and the signature given. This method (always) runs asynchronously.

Parameters
  • data – The data that was signed.

  • signature – The signature over the data.

Returns

The signer public key that signed the data to create the signature given.

abstract property security_module: Optional[ISecurityModule]

When this key is hosted by a security module, return a reference. If the key is freestanding (exists of its own outside any security module or key store), return None.

Returns

The security module of the key if the key is hosted.

abstract sign(data: bytes) bytes[source]

Sign the given data, only available if can_sign == True. This method (always) runs asynchronously.

Parameters

data – The data to be signed.

Returns

The signature, that is a future object that resolves to bytes.

class autobahn.wamp.interfaces.IMessage[source]

A WAMP message, e.g. one of the messages defined in the WAMP specification here.

abstract property MESSAGE_TYPE: int

WAMP message type code.

abstract static parse(wmsg) IMessage[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.

abstract serialize(serializer: ISerializer) bytes[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 – The wire level serializer to use.

Returns

The serialized 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: bool

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

abstract property NAME: str

Object serializer name (read-only).

abstract serialize(obj: Any) bytes[source]

Serialize an object to a byte string.

Parameters

obj – Object (any serializable type) to serialize.

Returns

Serialized bytes.

abstract unserialize(payload: bytes) List[Any][source]

Deserialize objects from a byte string.

Parameters

payload – Objects to deserialize.

Returns

List of deserialized (raw) objects.

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).

  • encoded_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.ISecurityModule[source]

Interface for key security modules, which

  • include filesystem and HSM backed persistent key implementations, and

  • provides secure key signature generation and verification with

  • two key types and signature schemes

The two key types and signature schemes support WAMP-cryptosign based authentication for WAMP sessions, and WAMP-XBR based signed transactions and data encryption.

References:

abstract property can_lock: bool

Flag indicating whether this security module can be locked, e.g. by a user passphrase or PIN.

Returns

Flag indicating whether the security module can be locked/unlocked at all.

abstract close()[source]

Close this security module. This method (always) runs asynchronously.

abstract create_key(key_type: str) int[source]

Create a new public-private asymmetric key pair, stored within the security module.

Parameters

key_type – Type of key to generate, e.g. "cryptosign" or "ethereum".

Returns

ID of new key.

abstract delete_key(key_no: int)[source]

Delete an existing key pair stored within the security module.

Parameters

key_no – ID of key to delete.

abstract get_counter(counter_no: int) int[source]

Return current value of the given persistent counter.

Parameters

counter_no – Counter to access.

Returns

Current value of counter, or 0 to indicate the counter does not exist (was never incremented).

abstract get_random(octets: int) bytes[source]

Generate random bytes within the security module.

Parameters

octets – Number of bytes (octets) to generate.

Returns

Random bytes, generated within the security module, e.g. in a HW RNG.

abstract increment_counter(counter_no: int) int[source]

Increment the given persistent counter and return the new value.

Parameters

counter_no – Counter to increment and access.

Returns

New value of counter, e.g. 1 once a counter was first incremented.

abstract property is_locked: bool

Check if this security module is currently locked.

Returns

Flag indicating whether the security module is currently locked.

abstract property is_open: bool

Check if the security module is currently opened. Security module operations can only be run when the module is opened.

Returns

Flag indicating whether the security module is currently opened.

abstract lock()[source]

Lock this security module. This method (always) runs asynchronously.

abstract open()[source]

Open this security module. This method (always) runs asynchronously.

abstract unlock()[source]

Unlock this security module. This method (always) runs asynchronously.

class autobahn.wamp.interfaces.ISerializer[source]

WAMP message serialization and deserialization.

abstract property MESSAGE_TYPE_MAP: Dict[int, IMessage]

Mapping of WAMP message type codes to WAMP message classes.

abstract property MIME_TYPE: str

The WAMP serialization format MIME type, e.g. "application/json" for JSON.

abstract property RAWSOCKET_SERIALIZER_ID: int

The WAMP serialization format ID as used for RawSocket, e.g. 1 for JSON.

abstract property SERIALIZER_ID: str

The WAMP serialization format ID as used for WebSocket, e.g. "json" (or "json.batched") for JSON.

abstract serialize(message: IMessage) Tuple[bytes, bool][source]

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

Parameters

message – The WAMP message to be serialized.

Returns

A pair (payload, is_binary).

abstract unserialize(payload: bytes, is_binary: Optional[bool] = None) List[IMessage][source]

Deserialize bytes from a transport and parse into WAMP messages.

Parameters
  • payload – Byte string from wire.

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

Returns

List of WAMP messages.

class autobahn.wamp.interfaces.ISession[source]

Interface for WAMP sessions.

abstract call(procedure: str, *args, **kwargs) Union[Any, CallResult][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 – The URI of the remote procedure to be called, e.g. "com.myapp.hello".

  • args – Any positional arguments for the call.

  • kwargs – Any keyword arguments for the call.

Returns

A Deferred/Future for the call result.

abstract property config: ComponentConfig

Configuration for session.

abstract define(exception: Exception, error: Optional[str] = None)[source]

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

Parameters
  • exception – The exception class to define an error mapping for.

  • error – 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() Optional[IPayloadCodec][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.

abstract is_attached() bool[source]

Check if the session has currently joined a realm.

abstract is_connected() bool[source]

Check if the underlying transport is connected.

abstract join(realm: str, authmethods: Optional[List[str]] = None, authid: Optional[str] = None, authrole: Optional[str] = None, authextra: Optional[Dict[str, Any]] = None, resumable: Optional[bool] = None, resume_session: Optional[int] = None, resume_token: Optional[str] = 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: Optional[str] = None, message: Optional[str] = None)[source]

Actively close this WAMP session.

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

  • message – 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: Challenge) str[source]

Callback fired when the peer demands authentication.

May return a Deferred/Future.

Parameters

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: SessionDetails)[source]

Callback fired when WAMP session has been established.

May return a Deferred/Future.

Parameters

details – Session information.

abstract onLeave(details: CloseDetails)[source]

Callback fired when WAMP session has is closed

Parameters

details – Close information for session.

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: Welcome) Optional[str][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.

Note

Before we let user code see the session – that is, before we fire “join” we give authentication instances a chance to abort the session. Usually this would be for “mutual authentication” scenarios. For example, WAMP-SCRAM uses this to confirm the server-signature.

Parameters

welcome – The WELCOME message received from the server

Returns

None, or an error message (using a fixed error URI wamp.error.cannot_authenticate).

abstract publish(topic: str, *args, **kwargs) Optional[Publication][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 – The URI of the topic to publish to, e.g. "com.myapp.mytopic1".

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

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

Returns

Acknowledgement for acknowledge publications - otherwise nothing.

abstract register(endpoint: Union[Callable, Any], procedure: Optional[str] = None, options: Optional[RegisterOptions] = None, prefix: Optional[str] = None, check_types: Optional[bool] = None) Union[Registration, List[Registration]][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 – The endpoint called under the procedure.

  • procedure – 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 – Options for registering.

  • prefix – 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 – 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)

abstract property session_details: Optional[SessionDetails]

Return details about the session, the same as initially provided to the ISession.onJoin() callback on an implementation.

abstract set_payload_codec(payload_codec: Optional[IPayloadCodec])[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 – The payload codec that should process application payload of the given encoding.

abstract subscribe(handler: Union[Callable, Any], topic: Optional[str] = None, options: Optional[SubscribeOptions] = None, check_types: Optional[bool] = None) Union[Subscription, List[Subscription]][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 – The event handler to receive events.

  • topic – 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 – Options for subscribing.

  • check_types – 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

abstract property transport: Optional[ITransport]

When the transport this session 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.

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 isOpen() bool[source]

Check if the transport is open for messaging.

Returns

True, if the transport is open.

abstract send(message: IMessage)[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 – The WAMP message to send over the transport.

abstract property transport_details: Optional[TransportDetails]

Return details about the transport (when the transport is open).

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

Callback fired when the transport has been closed.

Parameters

wasClean – Indicates if the transport has been closed regularly.

abstract onMessage(message: IMessage)[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 – The WAMP message received.

abstract onOpen(transport: ITransport)[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 – The WAMP transport.

WAMP Types

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

Information to accept a HELLO.

Parameters
  • realm – The realm the client is joined to.

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

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

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

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

  • authextra – 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, transaction_hash=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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the originating call, which may be used in the router to throttle or deduplicate the calls on the procedure. See the discussion here.

  • 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, transaction_hash=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').

  • transaction_hash (str) –

    An application provided transaction hash for the originating call, which may be used in the router to throttle or deduplicate the calls on the procedure. See the discussion here.

  • 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.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.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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the published event, which may be used in the router to throttle or deduplicate the events on the topic. See the discussion here.

  • 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.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.types.SessionDetails(realm: Optional[str] = None, session: Optional[int] = None, authid: Optional[str] = None, authrole: Optional[str] = None, authmethod: Optional[str] = None, authprovider: Optional[str] = None, authextra: Optional[Dict[str, Any]] = None, serializer: Optional[str] = None, transport: Optional[TransportDetails] = None, resumed: Optional[bool] = None, resumable: Optional[bool] = None, resume_token: Optional[str] = None)[source]

Provides details for a WAMP session upon open.

Parameters
  • realm – The WAMP realm this session is attached to, e.g. "realm1".

  • session – WAMP session ID of this session, e.g. 7069739155960584.

  • authid – The WAMP authid this session is joined as, e.g. "joe89"

  • authrole – The WAMP authrole this session is joined as, e.g. "user".

  • authmethod – The WAMP authentication method the session is authenticated under, e.g. "anonymous" or "wampcra".

  • authprovider – The WAMP authentication provider that handled the session authentication, e.g. "static" or "dynamic".

  • authextra – The (optional) WAMP authentication extra that was provided to the authenticating session.

  • serializer – The WAMP serializer (variant) this session is using, e.g. "json" or "cbor.batched".

  • transport – The details of the WAMP transport this session is hosted on (communicates over).

  • resumed – Whether the session is a resumed one.

  • resumable – Whether this session can be resumed later.

  • resume_token – The secure authorization token to resume the session.

property authextra: Optional[Dict[str, Any]]

The (optional) WAMP authentication extra that was provided to the authenticating session.

property authid: Optional[str]

The WAMP authid this session is joined as, e.g. "joe89"

property authmethod: Optional[str]

The WAMP authentication method the session is authenticated under, e.g. "anonymous" or "wampcra".

property authprovider: Optional[str]

The WAMP authentication provider that handled the session authentication, e.g. "static" or "dynamic".

property authrole: Optional[str]

The WAMP authrole this session is joined as, e.g. "user".

marshal() Dict[str, Any][source]
Returns

static parse(data: Dict[str, Any]) SessionDetails[source]
Parameters

data

Returns

property realm: Optional[str]

The WAMP realm this session is attached to, e.g. "realm1".

property resumable: Optional[bool]

Whether this session can be resumed later.

property resume_token: Optional[str]

The secure authorization token to resume the session.

property resumed: Optional[bool]

Whether the session is a resumed one.

property serializer: Optional[str]

The WAMP serializer (variant) this session is using, e.g. "json" or "cbor.batched".

property session: Optional[int]

WAMP session ID of this session, e.g. 7069739155960584.

property transport: Optional[TransportDetails]

The details of the WAMP transport this session is hosted on (communicates over).

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.types.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.types.TransportDetails(channel_type: Optional[int] = None, channel_framing: Optional[int] = None, channel_serializer: Optional[int] = None, own: Optional[str] = None, peer: Optional[str] = None, is_server: Optional[bool] = None, own_pid: Optional[int] = None, own_tid: Optional[int] = None, own_fd: Optional[int] = None, is_secure: Optional[bool] = None, channel_id: Optional[Dict[str, bytes]] = None, peer_cert: Optional[Dict[str, Any]] = None, websocket_protocol: Optional[str] = None, websocket_extensions_in_use: Optional[List[str]] = None, http_headers_received: Optional[Dict[str, Any]] = None, http_headers_sent: Optional[Dict[str, Any]] = None, http_cbtid: Optional[str] = None)[source]

Details about a WAMP transport used for carrying a WAMP session. WAMP can be communicated over different bidirectional underlying transport mechanisms, such as TCP, TLS, Serial connections or In-memory queues.

property channel_framing: Optional[int]

The message framing used on this transport, e.g. WebSocket.

property channel_id: Dict[str, bytes]

If this transport runs over a secure underlying connection, e.g. TLS, return a map of channel binding by binding type.

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:

property channel_serializer: Optional[int]

The message serializer used on this transport, e.g. CBOR (batched or unbatched).

property channel_type: Optional[int]

The underlying transport type, e.g. TCP.

property channel_typeid

Return a short type identifier string for the combination transport type, framing and serializer. Here are some common examples:

  • "tcp-websocket-json"

  • "tls-websocket-msgpack"

  • "memory-rawsocket-cbor"

  • "memory-rawsocket-flatbuffers"

  • "function-native-native"

Returns

property http_cbtid: Optional[str]

If the underlying connection uses a regular HTTP based WebSocket opening handshake, the HTTP cookie value of the WAMP tracking cookie if any is associated with this connection.

property http_headers_received: Dict[str, Any]

If the underlying connection uses a regular HTTP based WebSocket opening handshake, the HTTP request headers as received from the client on this connection.

property http_headers_sent: Dict[str, Any]

If the underlying connection uses a regular HTTP based WebSocket opening handshake, the HTTP response headers as sent from the server on this connection.

property is_secure: Optional[bool]

Flag indicating whether this transport runs over TLS (or similar), and hence is encrypting at the byte stream or datagram transport level (beneath WAMP payload encryption).

property is_server: Optional[bool]
Flag indicating whether this side of the peer is a “server” (on underlying transports that

follows a client-server approach).

property own: Optional[str]

https://github.com/crossbario/autobahn-python/blob/master/autobahn/websocket/test/test_websocket_url.py https://github.com/crossbario/autobahn-python/blob/master/autobahn/rawsocket/test/test_rawsocket_url.py

A WebSocket server URL:

  • ws://localhost

  • wss://example.com:443/ws

  • ws://62.146.25.34:80/ws

  • wss://localhost:9090/ws?foo=bar

A RawSocket server URL:

  • rs://crossbar:8081

  • rss://example.com

  • rs://unix:/tmp/file.sock

  • rss://unix:../file.sock

property own_fd: Optional[int]

The file descriptor (FD) at this end of the connection.

property own_pid: Optional[int]

The process ID (PID) of this end of the connection.

property own_tid: Optional[int]

The native thread ID of this end of the connection.

See https://docs.python.org/3/library/threading.html#threading.get_native_id.

Note

On CPython 3.7, instead of the native thread ID, a synthetic thread ID that has no direct meaning is used (via threading.get_ident()).

property peer: Optional[str]

The peer this transport is connected to.

process:12784 pipe

tcp4:127.0.0.1:38810 tcp4:127.0.0.1:8080 unix:/tmp/file.sock

property peer_cert: Dict[str, Any]

If this transport is using TLS and the TLS peer has provided a valid certificate, this attribute returns the peer certificate.

See here for details about the object returned.

property websocket_extensions_in_use: Optional[List[str]]

If the underlying connection uses a regular HTTP based WebSocket opening handshake, the WebSocket extensions negotiated, e.g. ["permessage-deflate", "client_no_context_takeover", "client_max_window_bits"].

property websocket_protocol: Optional[str]

If the underlying connection uses a regular HTTP based WebSocket opening handshake, the WebSocket subprotocol negotiated, e.g. "wamp.2.cbor.batched".

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.InvalidPayload[source]

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

exception autobahn.wamp.exception.InvalidUri[source]

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

exception autobahn.wamp.exception.InvalidUriError[source]

Exception raised when an invalid WAMP URI was used.

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.

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

The URI for a topic published with invalid argument types or a procedure called with invalid arguments types.

Parameters

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

WAMP Authentication and Encryption

class autobahn.wamp.auth.AuthScram(**kw)[source]

Bases: object

Implements “wamp-scram” authentication for components.

NOTE: This is a prototype of a draft spec; see https://github.com/wamp-proto/wamp-proto/issues/135

on_welcome(session, authextra)[source]

When the server is satisfied, it sends a ‘WELCOME’ message.

This hook allows us an opportunity to deny the session right before it gets set up – we check the server-signature thus authorizing the server and if it fails we drop the connection.

autobahn.wamp.auth.check_totp(secret, ticket)[source]

Check a TOTP value received from a principal trying to authenticate against the expected value computed from the secret shared between the principal and the authenticating entity.

The Internet can be slow, and clocks might not match exactly, so some leniency is allowed. RFC6238 recommends looking an extra time step in either direction, which essentially opens the window from 30 seconds to 90 seconds.

Parameters
  • secret (unicode) – The secret shared between the principal (eg a client) that is authenticating, and the authenticating entity (eg a server).

  • ticket (unicode) – The TOTP value to be checked.

Returns

True if the TOTP value is correct, else False.

Return type

bool

autobahn.wamp.auth.compute_totp(secret, offset=0)[source]

Computes the current TOTP code.

Parameters
  • secret (unicode) – Base32 encoded secret.

  • offset (int) – Time offset (in steps, use eg -1, 0, +1 for compliance with RFC6238) for which to compute TOTP.

Returns

TOTP for current time (+/- offset).

Return type

unicode

autobahn.wamp.auth.compute_wcs(key, challenge)[source]

Compute an WAMP-CRA authentication signature from an authentication challenge and a (derived) key.

Parameters
  • key (bytes) – The key derived (via PBKDF2) from the secret.

  • challenge (bytes) – The authentication challenge to sign.

Returns

The authentication signature.

Return type

bytes

autobahn.wamp.auth.create_authenticator(name, **kwargs)[source]

Accepts various keys and values to configure an authenticator. The valid keys depend on the kind of authenticator but all can understand: authextra, authid and authrole

Returns

an instance implementing IAuthenticator with the given configuration.

autobahn.wamp.auth.derive_key(secret, salt, iterations=1000, keylen=32)[source]

Computes a derived cryptographic key from a password according to PBKDF2.

Parameters
  • secret (bytes or unicode) – The secret.

  • salt (bytes or unicode) – The salt to be used.

  • iterations (int) – Number of iterations of derivation algorithm to run.

  • keylen (int) – Length of the key to derive in bytes.

Returns

The derived key in Base64 encoding.

Return type

bytes

autobahn.wamp.auth.derive_scram_credential(email: str, password: str, salt: Optional[bytes] = None) Dict[source]

Derive WAMP-SCRAM credentials from user email and password. The SCRAM parameters used are the following (these are also contained in the returned credentials):

  • kdf argon2id-13

  • time cost 4096

  • memory cost 512

  • parallelism 1

See draft-irtf-cfrg-argon2 and argon2-cffi.

Parameters
  • email – User email.

  • password – User password.

  • salt – Optional salt to use (must be 16 bytes long). If none is given, compute salt from email as salt = SHA256(email)[:16].

Returns

WAMP-SCRAM credentials. When serialized, the returned credentials can be copy-pasted into the config.json node configuration for a Crossbar.io node.

autobahn.wamp.auth.generate_totp_secret(length=10)[source]

Generates a new Base32 encoded, random secret.

Parameters

length (int) – The length of the entropy used to generate the secret.

Returns

The generated secret in Base32 (letters A-Z and digits 2-7). The length of the generated secret is length * 8 / 5 octets.

Return type

unicode

autobahn.wamp.auth.generate_wcs(length=14)[source]

Generates a new random secret for use with WAMP-CRA.

The secret generated is a random character sequence drawn from

  • upper and lower case latin letters

  • digits

Parameters

length (int) – The length of the secret to generate.

Returns

The generated secret. The length of the generated is length octets.

Return type

bytes

autobahn.wamp.auth.pbkdf2(data, salt, iterations=1000, keylen=32, hashfunc=None)[source]

Returns a binary digest for the PBKDF2 hash algorithm of data with the given salt. It iterates iterations time and produces a key of keylen bytes. By default SHA-256 is used as hash function, a different hashlib hashfunc can be provided.

Parameters
  • data (bytes) – The data for which to compute the PBKDF2 derived key.

  • salt (bytes) – The salt to use for deriving the key.

  • iterations (int) – The number of iterations to perform in PBKDF2.

  • keylen (int) – The length of the cryptographic key to derive.

  • hashfunc (str) – Name of the hash algorithm to use

Returns

The derived cryptographic key.

Return type

bytes

class autobahn.wamp.cryptosign.CryptosignAuthextra(pubkey: Optional[bytes] = None, challenge: Optional[bytes] = None, channel_binding: Optional[str] = None, channel_id: Optional[bytes] = None, trustroot: Optional[bytes] = None, realm: Optional[bytes] = None, chain_id: Optional[int] = None, block_no: Optional[int] = None, delegate: Optional[bytes] = None, seeder: Optional[bytes] = None, bandwidth: Optional[int] = None, signature: Optional[bytes] = None)[source]

WAMP-Cryptosign authextra object.

class autobahn.wamp.cryptosign.CryptosignKey(key, can_sign: bool, security_module: Optional[ISecurityModule] = None, key_no: Optional[int] = None, comment: Optional[str] = None)[source]

A cryptosign private key for signing, and hence usable for authentication or a public key usable for verification (but can’t be used for signing).

property can_sign: bool

Implements autobahn.wamp.interfaces.IKey.can_sign().

property comment: Optional[str]

Implements autobahn.wamp.interfaces.IKey.comment().

classmethod from_file(filename: str, comment: Optional[str] = None) CryptosignKey[source]

Load an Ed25519 (private) signing key (actually, the seed for the key) from a raw file of 32 bytes length. This can be any random byte sequence, such as generated from Python code like

os.urandom(32)

or from the shell

dd if=/dev/urandom of=client02.key bs=1 count=32

Parameters
  • filename – Filename of the key.

  • comment – Comment for key (optional).

classmethod from_keyfile(keyfile: str) CryptosignKey[source]

Create a public or private key from reading the given public or private key file.

Here is an example key file that includes an CryptosignKey private key private-key-ed25519, which is loaded in this function, and other fields, which are ignored by this function:

This is a comment (all lines until the first empty line are comments indeed).

creator: oberstet@intel-nuci7
created-at: 2022-07-05T12:29:48.832Z
user-id: oberstet@intel-nuci7
public-key-ed25519: 7326d9dc0307681cc6940fde0e60eb31a6e4d642a81e55c434462ce31f95deed
public-adr-eth: 0x10848feBdf7f200Ba989CDf7E3eEB3EC03ae7768
private-key-ed25519: f750f42b0430e28a2e272c3cedcae4dcc4a1cf33bc345c35099d3322626ab666
private-key-eth: 4d787714dcb0ae52e1c5d2144648c255d660b9a55eac9deeb80d9f506f501025
Parameters

keyfile – Path (relative or absolute) to a public or private keys file.

Returns

New instance of CryptosignKey

classmethod from_seedphrase(seedphrase: str, index: int = 0) CryptosignKey[source]

Create a private key from the given BIP-39 mnemonic seed phrase and index, which can be used to sign and create signatures.

Parameters
  • seedphrase – The BIP-39 seedphrase (“Mnemonic”) from which to derive the account.

  • index – The account index in account hierarchy defined by the seedphrase.

Returns

New instance of EthereumKey

classmethod from_ssh_bytes(key_data: str) CryptosignKey[source]

Load an Ed25519 key from SSH key file. The key file can be a (private) signing key (from a SSH private key file) or a (public) verification key (from a SSH public key file). A private key file must be passphrase-less.

classmethod from_ssh_file(filename: str) CryptosignKey[source]

Load an Ed25519 key from a SSH key file. The key file can be a (private) signing key (from a SSH private key file) or a (public) verification key (from a SSH public key file). A private key file must be passphrase-less.

property key_no: Optional[int]

Implements autobahn.wamp.interfaces.IKey.key_no().

property key_type: str

Implements autobahn.wamp.interfaces.IKey.key_type().

public_key(binary: bool = False) Union[str, bytes][source]

Returns the public key part of a signing key or the (public) verification key.

Returns

The public key in Hex encoding.

Return type

str or None

property security_module: Optional[ISecurityModule]

Implements autobahn.wamp.interfaces.IKey.security_module().

sign(data: bytes) bytes[source]

Implements autobahn.wamp.interfaces.IKey.sign().

sign_challenge(challenge: Challenge, channel_id: Optional[bytes] = None, channel_id_type: Optional[str] = None) bytes[source]

Implements autobahn.wamp.interfaces.ICryptosignKey.sign_challenge().

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.

class autobahn.wamp.cryptobox.Key(originator_priv=None, originator_pub=None, responder_priv=None, responder_pub=None)[source]

Holds originator and responder keys for an URI.

The originator is either a caller or a publisher. The responder is either a callee or subscriber.

class autobahn.wamp.cryptobox.KeyRing(default_key=None)[source]

A keyring holds (cryptobox) public-private key pairs for use with WAMP-cryptobox payload encryption. The keyring can be set on a WAMP session and then transparently will get used for encrypting and decrypting WAMP message payloads.

Create a new key ring to hold public and private keys mapped from an URI space.

decode(is_originating, uri, encoded_payload)[source]

Decrypt the given WAMP URI and EncodedPayload into a tuple (uri, args, kwargs).

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

Encrypt the given WAMP URI, args and kwargs into an EncodedPayload instance, or None if the URI should not be encrypted.

generate_key()[source]

Generate a new private key and return a pair with the base64 encodings of (priv_key, pub_key).

generate_key_hex()[source]

Generate a new private key and return a pair with the hex encodings of (priv_key, pub_key).

set_key(uri, key)[source]

Add a key set for a given URI.

WAMP Serializer

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

CBOR serializer based on cbor2.

This CBOR serializer has proper support for arbitrary precision decimals, via tagged decimal fraction encoding, as described in RFC7049 section 2.4.3.

Parameters

batched (bool) – Flag that controls whether serializer operates in batched mode.

BINARY = True

Flag that indicates whether this serializer needs a binary clean transport.

serialize(obj)[source]

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

unserialize(payload)[source]

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

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

Ctor.

Parameters

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

MIME_TYPE = 'application/cbor'

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

RAWSOCKET_SERIALIZER_ID = 3

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

SERIALIZER_ID = 'cbor'

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

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

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

MIME_TYPE = 'application/x-flatbuffers'

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

RAWSOCKET_SERIALIZER_ID = 5

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

SERIALIZER_ID = 'flatbuffers'

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

class autobahn.wamp.serializer.JsonSerializer(batched=False, use_binary_hex_encoding=False, use_decimal_from_str=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.MsgPackSerializer(batched=False)[source]

Ctor.

Parameters

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

MIME_TYPE = 'application/x-msgpack'

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

RAWSOCKET_SERIALIZER_ID = 2

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

SERIALIZER_ID = 'msgpack'

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: IMessage) Tuple[bytes, bool][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: bytes, isBinary: Optional[bool] = None) List[IMessage][source]

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

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

Ctor.

Parameters

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

MIME_TYPE = 'application/ubjson'

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

RAWSOCKET_SERIALIZER_ID = 4

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

SERIALIZER_ID = 'ubjson'

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

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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the originating call, which may be used in the router to throttle or deduplicate the calls on the procedure. See the discussion here.

  • 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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the originating call, which may be used in the router to throttle or deduplicate the calls on the procedure. See the discussion here.

  • 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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the originating call, which may be used in the router to throttle or deduplicate the calls on the procedure. See the discussion here.

  • 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, transaction_hash=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.

  • transaction_hash (str) –

    An application provided transaction hash for the published event, which may be used in the router to throttle or deduplicate the events on the topic. See the discussion here.

  • 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_extra(value: Any, message: str = 'WAMP message invalid') Dict[str, Any][source]

Check a value for being a valid WAMP extra dictionary.

If the value is not a valid WAMP extra dictionary, raises autobahn.wamp.exception.ProtocolError, otherwise return the value.

Parameters
  • value – The value to check.

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

Returns

The extra dictionary (if valid).

Raises

instance of autobahn.wamp.exception.ProtocolError

autobahn.wamp.message.check_or_raise_id(value: Any, message: str = 'WAMP message invalid') int[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 – The value to check.

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

Returns

The ID value (if valid).

Raises

instance of autobahn.wamp.exception.ProtocolError

autobahn.wamp.message.check_or_raise_realm_name(value, message='WAMP message invalid', allow_eth=True)[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.InvalidUriError, otherwise returns the value.

Parameters
  • value – The value to check, e.g. "realm1" or "com.example.myapp" or "eth.example".

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

  • allow_eth – If True, allow Ethereum addresses as realm names, e.g. "0xe59C7418403CF1D973485B36660728a5f4A8fF9c".

Returns

The URI value (if valid).

Raises

instance of autobahn.wamp.exception.InvalidUriError

autobahn.wamp.message.check_or_raise_uri(value: Any, message: str = 'WAMP message invalid', strict: bool = False, allow_empty_components: bool = False, allow_last_empty: bool = False, allow_none: bool = False) str[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.InvalidUriError, otherwise returns the value.

Parameters
  • value – The value to check.

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

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

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

  • allow_last_empty – If True, allow the last URI component to be empty (for prefix based subscriptions and registrations).

  • allow_none – If True, allow None for URIs.

Returns

The URI value (if valid).

Raises

instance of autobahn.wamp.exception.InvalidUriError

autobahn.wamp.message.identify_realm_name_category(value: Any) Optional[str][source]

Identify the real name category of the given value:

  • "standalone": A normal, standalone WAMP realm name, e.g. "realm1".

  • "eth": An Ethereum address, e.g. "0xe59C7418403CF1D973485B36660728a5f4A8fF9c".

  • "ens": An Ethereum ENS name, e.g. "wamp-proto.eth".

  • "reverse_ens": An Ethereum ENS name in reverse notation, e.g. "eth.wamp-proto".

  • None: The value is not a WAMP realm name.

Parameters

value – The value for which to identify realm name category.

Returns

The category identified, one of ["standalone", "eth", "ens", "reverse-ens"] or None.

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