Module autobahn.rawsocket

WAMP-RawSocket is an alternative WAMP transport that has less overhead compared to WebSocket, and is vastly simpler to implement. It can run over any stream based underlying transport, such as TCP or Unix domain socket. However, it does NOT run into the browser.

RawSocket Utilities

RawSocket utilities that do not depend on the specific networking framework being used (Twisted or asyncio).

autobahn.rawsocket.util.create_url(hostname, port=None, isSecure=False)[source]

Create a RawSocket URL from components.

Parameters
  • hostname (str) – RawSocket server hostname (for TCP/IP sockets) or filesystem path (for Unix domain sockets).

  • port (int or str) – For TCP/IP sockets, RawSocket service port or None (to select default ports 80 or 443 depending on isSecure. When hostname=="unix", this defines the path to the Unix domain socket instead of a TCP/IP network socket.

  • isSecure (bool) – Set True for secure RawSocket (rss scheme).

Returns

Constructed RawSocket URL.

Return type

str

autobahn.rawsocket.util.parse_url(url)[source]

Parses as RawSocket URL into it’s components and returns a tuple:

  • isSecure is a flag which is True for rss URLs.

  • host is the hostname or IP from the URL.

and for TCP/IP sockets:

  • tcp_port is the port from the URL or standard port derived from scheme (rs => 80, rss => 443).

or for Unix domain sockets:

  • uds_path is the path on the local host filesystem.

Parameters

url (str) – A valid RawSocket URL, i.e. rs://localhost:9000 for TCP/IP sockets or rs://unix:/tmp/file.sock for Unix domain sockets (UDS).

Returns

A 3-tuple (isSecure, host, tcp_port) (TCP/IP) or (isSecure, host, uds_path) (UDS).

Return type

tuple