This document describes the current stable version of py-amqp (5.0). For development docs, go here.
amqp.transport¶
Transport implementation.
- class amqp.transport._AbstractTransport(host, connect_timeout=None, read_timeout=None, write_timeout=None, socket_settings=None, raise_on_initial_eintr=True, **kwargs)[source]¶
Common superclass for TCP and SSL transports.
- PARAMETERS:
host: str
Broker address in format
HOSTNAME:PORT.connect_timeout: int
Timeout of creating new connection.
read_timeout: int
sets
SO_RCVTIMEOparameter of socket.write_timeout: int
sets
SO_SNDTIMEOparameter of socket.socket_settings: dict
dictionary containing optname and
optvalpassed tosetsockopt(2).raise_on_initial_eintr: bool
when True,
socket.timeoutis raised when exception is received during first read. See_read()for details.
- read_frame(unpack=<built-in function unpack>)[source]¶
Parse AMQP frame.
Frame has following format:
0 1 3 7 size+7 size+8 +------+---------+---------+ +-------------+ +-----------+ | type | channel | size | | payload | | frame-end | +------+---------+---------+ +-------------+ +-----------+ octet short long 'size' octets octet
- class amqp.transport.SSLTransport(host, connect_timeout=None, ssl=None, **kwargs)[source]¶
Transport that works over SSL.
- PARAMETERS:
host: str
Broker address in format
HOSTNAME:PORT.connect_timeout: int
Timeout of creating new connection.
ssl: bool|dict
- parameters of TLS subsystem.
when
sslis not dictionary, defaults of TLS are used- otherwise:
if
ssldictionary containscontextkey,_wrap_contextis used for wrapping socket.contextis a dictionary passed to_wrap_contextas context parameter. All others items fromsslargument are passed assslopts.if
ssldictionary does not containcontextkey,_wrap_socket_sniis used for wrapping socket. All items insslargument are passed to_wrap_socket_snias parameters.
kwargs:
additional arguments of
_AbstractTransportclass
- _wrap_context(sock, sslopts, check_hostname=None, **ctx_options)[source]¶
Wrap socket without SNI headers.
- PARAMETERS:
sock: socket.socket
Socket to be wrapped.
sslopts: dict
Parameters of
ssl.SSLContext.wrap_socket.check_hostname
Whether to match the peer cert’s hostname. See
ssl.SSLContext.check_hostnamefor details.ctx_options
Parameters of
ssl.create_default_context.
- _wrap_socket_sni(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=None, ca_certs=None, do_handshake_on_connect=False, suppress_ragged_eofs=True, server_hostname=None, ciphers=None, ssl_version=None)[source]¶
Socket wrap with SNI headers.
stdlib
ssl.SSLContext.wrap_socketmethod augmented with support for setting the server_hostname field required for SNI hostname header.- PARAMETERS:
sock: socket.socket
Socket to be wrapped.
keyfile: str
Path to the private key
certfile: str
Path to the certificate
server_side: bool
Identifies whether server-side or client-side behavior is desired from this socket. See
wrap_socketfor details.cert_reqs: ssl.VerifyMode
When set to other than
ssl.CERT_NONE, peers certificate is checked. Possible values aressl.CERT_NONE,ssl.CERT_OPTIONALandssl.CERT_REQUIRED.ca_certs: str
Path to “certification authority” (CA) certificates used to validate other peers’ certificates when
cert_reqsis other thanssl.CERT_NONE.do_handshake_on_connect: bool
Specifies whether to do the SSL handshake automatically. See
wrap_socketfor details.suppress_ragged_eofs (bool):
See
wrap_socketfor details.server_hostname: str
Specifies the hostname of the service which we are connecting to. See
wrap_socketfor details.ciphers: str
Available ciphers for sockets created with this context. See
ssl.SSLContext.set_ciphersssl_version:
Protocol of the SSL Context. The value is one of
ssl.PROTOCOL_*constants.
- class amqp.transport.TCPTransport(host, connect_timeout=None, read_timeout=None, write_timeout=None, socket_settings=None, raise_on_initial_eintr=True, **kwargs)[source]¶
Transport that deals directly with TCP socket.
All parameters are
_AbstractTransportclass.
- class amqp.transport.Transport(host, connect_timeout=None, ssl=False, **kwargs)[source]¶
Create transport.
Given a few parameters from the Connection constructor, select and create a subclass of
_AbstractTransport.PARAMETERS:
host: str
Broker address in format
HOSTNAME:PORT.connect_timeout: int
Timeout of creating new connection.
ssl: bool|dict
If set,
SSLTransportis used andsslparameter is passed to it. OtherwiseTCPTransportis used.kwargs:
additional arguments of
_AbstractTransportclass