From f66a969275611adc35dd69953d059d9c51e58735 Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Tue, 13 Feb 2024 11:17:09 -0800 Subject: [PATCH 1/5] enable win-cert-store fix --- .github/workflows/ci.yml | 7 +++---- samples/pubsub.py | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 258a3ae1..a1076514 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,10 +63,9 @@ jobs: - name: run PubSub sample run: | python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json - # TODO Temporarily disable this job. Enable it after the issue is properly fixes. - # - name: run Windows Certificate Connect sample - # run: | - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + - name: run Windows Certificate Connect sample + run: | + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - name: configure AWS credentials (MQTT5 samples) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/samples/pubsub.py b/samples/pubsub.py index 0229f5df..65a2883b 100644 --- a/samples/pubsub.py +++ b/samples/pubsub.py @@ -52,7 +52,7 @@ def on_resubscribe_complete(resubscribe_future): # Callback when the subscribed topic receives a message def on_message_received(topic, payload, dup, qos, retain, **kwargs): - print("Received message from topic '{}': {}".format(topic, payload)) + print("Received message from topic '{}' with {}: {}".format(topic, qos, payload)) global received_count received_count += 1 if received_count == cmdData.input_count: @@ -91,7 +91,8 @@ def on_connection_closed(connection, callback_data): on_connection_resumed=on_connection_resumed, client_id=cmdData.input_clientId, clean_session=False, - keep_alive_secs=30, + keep_alive_secs=10, + ping_timeout_ms=500, http_proxy_options=proxy_options, on_connection_success=on_connection_success, on_connection_failure=on_connection_failure, @@ -135,10 +136,16 @@ def on_connection_closed(connection, callback_data): message = "{} [{}]".format(message_string, publish_count) print("Publishing message to topic '{}': {}".format(message_topic, message)) message_json = json.dumps(message) - mqtt_connection.publish( - topic=message_topic, - payload=message_json, - qos=mqtt.QoS.AT_LEAST_ONCE) + if(publish_count % 2 == 0): + mqtt_connection.publish( + topic=message_topic, + payload=message_json, + qos=mqtt.QoS.AT_LEAST_ONCE) + else: + mqtt_connection.publish( + topic=message_topic, + payload=message_json, + qos=mqtt.QoS.AT_MOST_ONCE) time.sleep(1) publish_count += 1 From 4881c462b9f81fbfdf9bffc16b4ddda6a4a4e851 Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Tue, 13 Feb 2024 11:19:45 -0800 Subject: [PATCH 2/5] update run_sample_ci script --- utils/run_sample_ci.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index 512d6fe2..600cd076 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -147,7 +147,18 @@ def make_windows_pfx_file(certificate_file_path, private_key_path, pfx_file_path # Import the PFX into the Windows Certificate Store # (Passing '$mypwd' is required even though it is empty and our certificate has no password. It fails CI otherwise) - import_pfx_arguments = ["powershell.exe", "Import-PfxCertificate", "-FilePath", pfx_file_path, "-CertStoreLocation", "Cert:\\" + pfx_certificate_store_location, "-Password", "$mypwd"] + import_pfx_arguments = [ + "powershell.exe", + # Powershell 7.3 introduced an issue where launching powershell from cmd would not set PSModulePath correctly. + # As a workaround, we set `PSModulePath` to empty so powershell would automatically reset the PSModulePath to default. + # More details: https://github.com/PowerShell/PowerShell/issues/18530 + "$env:PSModulePath = '';", + "Import-PfxCertificate", + "-FilePath", pfx_file_path, + "-CertStoreLocation", + "Cert:\\" + pfx_certificate_store_location, + "-Password", + "$mypwd"] import_pfx_run = subprocess.run(args=import_pfx_arguments, shell=True, stdout=subprocess.PIPE) if (import_pfx_run.returncode != 0): print ("ERROR: Could not import PFX certificate into Windows store!") From e9f410fbf527f04aa9ecf4c8d8f29919d51cc55b Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Tue, 13 Feb 2024 11:38:22 -0800 Subject: [PATCH 3/5] use builder v0.9.56 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1076514..c49b8d4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: - 'docs' env: - BUILDER_VERSION: v0.9.53 + BUILDER_VERSION: v0.9.56 BUILDER_SOURCE: releases BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net PACKAGE_NAME: aws-iot-device-sdk-python-v2 From b0e42e4645ee8cd0b204e9230951e2a0b0265634 Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Wed, 14 Feb 2024 09:16:15 -0800 Subject: [PATCH 4/5] revert local changes --- samples/pubsub.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/samples/pubsub.py b/samples/pubsub.py index 65a2883b..345331db 100644 --- a/samples/pubsub.py +++ b/samples/pubsub.py @@ -52,7 +52,6 @@ def on_resubscribe_complete(resubscribe_future): # Callback when the subscribed topic receives a message def on_message_received(topic, payload, dup, qos, retain, **kwargs): - print("Received message from topic '{}' with {}: {}".format(topic, qos, payload)) global received_count received_count += 1 if received_count == cmdData.input_count: @@ -91,8 +90,7 @@ def on_connection_closed(connection, callback_data): on_connection_resumed=on_connection_resumed, client_id=cmdData.input_clientId, clean_session=False, - keep_alive_secs=10, - ping_timeout_ms=500, + keep_alive_secs=30, http_proxy_options=proxy_options, on_connection_success=on_connection_success, on_connection_failure=on_connection_failure, @@ -136,16 +134,10 @@ def on_connection_closed(connection, callback_data): message = "{} [{}]".format(message_string, publish_count) print("Publishing message to topic '{}': {}".format(message_topic, message)) message_json = json.dumps(message) - if(publish_count % 2 == 0): - mqtt_connection.publish( - topic=message_topic, - payload=message_json, - qos=mqtt.QoS.AT_LEAST_ONCE) - else: - mqtt_connection.publish( - topic=message_topic, - payload=message_json, - qos=mqtt.QoS.AT_MOST_ONCE) + mqtt_connection.publish( + topic=message_topic, + payload=message_json, + qos=mqtt.QoS.AT_LEAST_ONCE) time.sleep(1) publish_count += 1 From 6d3fb760aa55043af7a6b5f1622a21c5da8ab5a8 Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Wed, 14 Feb 2024 09:17:06 -0800 Subject: [PATCH 5/5] revert print message --- samples/pubsub.py | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/pubsub.py b/samples/pubsub.py index 345331db..0229f5df 100644 --- a/samples/pubsub.py +++ b/samples/pubsub.py @@ -52,6 +52,7 @@ def on_resubscribe_complete(resubscribe_future): # Callback when the subscribed topic receives a message def on_message_received(topic, payload, dup, qos, retain, **kwargs): + print("Received message from topic '{}': {}".format(topic, payload)) global received_count received_count += 1 if received_count == cmdData.input_count: