in awscrt/mqtt.py [0:0]
def __init__(self,
client,
host_name,
port,
client_id,
clean_session=True,
on_connection_interrupted=None,
on_connection_resumed=None,
reconnect_min_timeout_secs=5,
reconnect_max_timeout_secs=60,
keep_alive_secs=1200,
ping_timeout_ms=3000,
protocol_operation_timeout_ms=0,
will=None,
username=None,
password=None,
socket_options=None,
use_websockets=False,
websocket_proxy_options=None,
websocket_handshake_transform=None,
proxy_options=None
):
assert isinstance(client, Client)
assert callable(on_connection_interrupted) or on_connection_interrupted is None
assert callable(on_connection_resumed) or on_connection_resumed is None
assert isinstance(will, Will) or will is None
assert isinstance(socket_options, SocketOptions) or socket_options is None
assert isinstance(websocket_proxy_options, HttpProxyOptions) or websocket_proxy_options is None
assert isinstance(proxy_options, HttpProxyOptions) or proxy_options is None
assert callable(websocket_handshake_transform) or websocket_handshake_transform is None
if reconnect_min_timeout_secs > reconnect_max_timeout_secs:
raise ValueError("'reconnect_min_timeout_secs' cannot exceed 'reconnect_max_timeout_secs'")
if keep_alive_secs * 1000 <= ping_timeout_ms:
raise ValueError("'keep_alive_secs' duration must be longer than 'ping_timeout_ms'")
if proxy_options and websocket_proxy_options:
raise ValueError("'websocket_proxy_options' has been deprecated in favor of 'proxy_options'. "
"Both parameters may not be set.")
super().__init__()
# init-only
self.client = client
self._on_connection_interrupted_cb = on_connection_interrupted
self._on_connection_resumed_cb = on_connection_resumed
self._use_websockets = use_websockets
self._ws_handshake_transform_cb = websocket_handshake_transform
# may be changed at runtime, take effect the the next time connect/reconnect occurs
self.client_id = client_id
self.host_name = host_name
self.port = port
self.clean_session = clean_session
self.reconnect_min_timeout_secs = reconnect_min_timeout_secs
self.reconnect_max_timeout_secs = reconnect_max_timeout_secs
self.keep_alive_secs = keep_alive_secs
self.ping_timeout_ms = ping_timeout_ms
self.protocol_operation_timeout_ms = protocol_operation_timeout_ms
self.will = will
self.username = username
self.password = password
self.socket_options = socket_options if socket_options else SocketOptions()
self.proxy_options = proxy_options if proxy_options else websocket_proxy_options
self._binding = _awscrt.mqtt_client_connection_new(
self,
client,
use_websockets,
)