Module autobahn.wamp.component


This is common code for both Twisted and asyncio components; see either autobahn.twisted.component.Component or autobahn.asyncio.component.Component for the concrete implementations.

class autobahn.wamp.component.Component(main=None, transports=None, config=None, realm=u'realm1', extra=None, authentication=None, session_factory=None, is_fatal=None)[source]

A WAMP application component. A component holds configuration for (and knows how to create) transports and sessions.

  • main (callable taking 2 args: reactor, ISession) – After a transport has been connected and a session has been established and joined to a realm, this (async) procedure will be run until it finishes – which signals that the component has run to completion. In this case, it usually doesn’t make sense to use the on_* kwargs. If you do not pass a main() procedure, the session will not be closed (unless you arrange for .leave() to be called).
  • transports (None or unicode or list of dicts) –

    Transport configurations for creating transports. Each transport can be a WAMP URL, or a dict containing the following configuration keys:

    • type (optional): websocket (default) or rawsocket
    • url: the router URL
    • endpoint (optional, derived from URL if not provided):
      • type: “tcp” or “unix”
      • host, port: only for TCP
      • path: only for unix
      • timeout: in seconds
      • tls: True or (under Twisted) an twisted.internet.ssl.IOpenSSLClientComponentCreator instance (such as returned from twisted.internet.ssl.optionsForClientTLS) or CertificateOptions instance.
  • realm (unicode) – the realm to join
  • authentication (dict mapping auth_type to dict) – configuration of authenticators
  • session_factory (callable) – if None, ApplicationSession is used, otherwise a callable taking a single config argument that is used to create a new ApplicationSession instance.
  • is_fatal (callable taking one arg, or None) – a callable taking a single argument, an Exception instance. The callable should return True if this error is “fatal”, meaning we should not try connecting to the current transport again. The default behavior (on None) is to always return False