aws_connector.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:snap-to-cloud-examples 作者: synapse-wireless 项目源码 文件源码
def connect_mqtt_client(self):
        """Connect to the AWS IoT endpoint."""
        # Create MQTT client
        self.mqtt_client = mqtt.Client(self.client_id)
        self.mqtt_client.on_log = self._on_mqtt_log

        # Authenticate using TLS mutual authentication with a client certificate
        cafile = self.get_abs_path(CAFILE)
        certificate_cert = self.get_abs_path(CERTIFICATE_CERT)
        certificate_key = self.get_abs_path(CERTIFICATE_KEY)
        self.mqtt_client.tls_set(cafile, certificate_cert, certificate_key, ssl.CERT_REQUIRED, ssl.PROTOCOL_TLSv1_2)

        # 8883 is the default port for MQTT over SSL/TLS
        self.mqtt_client.connect(self.endpoint_address, port=8883)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号