This document is for py-amqp's development version, which can be significantly different from previous releases. Get the stable docs here: 5.3.
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_RCVTIMEO
parameter of socket.write_timeout: int
sets
SO_SNDTIMEO
parameter of socket.socket_settings: dict
dictionary containing optname and
optval
passed tosetsockopt(2)
.raise_on_initial_eintr: bool
when True,
socket.timeout
is raised when exception is received during first read. See_read()
for details.
- connect_timeout¶
- connection¶
- host¶
- port¶
- raise_on_initial_eintr¶
- 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
- read_timeout¶
- sock¶
- socket_settings¶
- write_timeout¶
- 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
ssl
is not dictionary, defaults of TLS are used- otherwise:
if
ssl
dictionary containscontext
key,_wrap_context
is used for wrapping socket.context
is a dictionary passed to_wrap_context
as context parameter. All others items fromssl
argument are passed assslopts
.if
ssl
dictionary does not containcontext
key,_wrap_socket_sni
is used for wrapping socket. All items inssl
argument are passed to_wrap_socket_sni
as parameters.
kwargs:
additional arguments of
_AbstractTransport
class
- _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_hostname
for 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_socket
method 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_socket
for details.cert_reqs: ssl.VerifyMode
When set to other than
ssl.CERT_NONE
, peers certificate is checked. Possible values aressl.CERT_NONE
,ssl.CERT_OPTIONAL
andssl.CERT_REQUIRED
.ca_certs: str
Path to “certification authority” (CA) certificates used to validate other peers’ certificates when
cert_reqs
is other thanssl.CERT_NONE
.do_handshake_on_connect: bool
Specifies whether to do the SSL handshake automatically. See
wrap_socket
for details.suppress_ragged_eofs (bool):
See
wrap_socket
for details.server_hostname: str
Specifies the hostname of the service which we are connecting to. See
wrap_socket
for details.ciphers: str
Available ciphers for sockets created with this context. See
ssl.SSLContext.set_ciphers
ssl_version:
Protocol of the SSL Context. The value is one of
ssl.PROTOCOL_*
constants.
- sslopts¶
- 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
_AbstractTransport
class.- connect_timeout¶
- connection¶
- host¶
- port¶
- raise_on_initial_eintr¶
- read_timeout¶
- sock¶
- socket_settings¶
- write_timeout¶
- 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,
SSLTransport
is used andssl
parameter is passed to it. OtherwiseTCPTransport
is used.kwargs:
additional arguments of
_AbstractTransport
class