Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azure-iot-sdk] [v2.12.0] ensure_desired_properties kwarg at False seems not work #1158

Closed
fhouge opened this issue Oct 20, 2023 · 3 comments
Assignees

Comments

@fhouge
Copy link

fhouge commented Oct 20, 2023

I try to disable the following feature: Fetching the latest twin when reconnecting.
I use the azure-iot-sdk-python v2.12.0.

In the release, I see:
Fetching the latest twin when reconnecting is now optional (using the ensure_desired_properties kwarg)

So, I try to set to False this parameter with the following call when I create my module client:

self.client = IoTHubModuleClient.create_from_edge_environment(ensure_desired_properties=False)

I build my module with this change and i deploy it on my device.
When I test this change, I see the following message at the module launch:
INFO get_twin(async_clients.py:442): Getting twin
--> as expected

But one hour later and each following hour, I see:
INFO _handle_pipeline_event(pipeline_stages_iothub.py:129): EnsureDesiredPropertiesStage: Reconnected. Getting twin
--> not expected with ensure_desired_properties parameter at False.

I try the following hack after the call to create_from_edge_environment without kwargs parameter:

self.client = IoTHubModuleClient.create_from_edge_environment()
self.client._mqtt_pipeline._pipeline.nucleus.pipeline_configuration.ensure_desired_properties = False

And with this hack, the following message disappear each hour as expected:
INFO _handle_pipeline_event(pipeline_stages_iothub.py:129): EnsureDesiredPropertiesStage: Reconnected. Getting twin

I find in the SDK code the following lines:

        # Pipeline Config setup
        config_kwargs = _get_config_kwargs(**kwargs)
        pipeline_configuration = pipeline.IoTHubPipelineConfig(
            device_id=device_id,
            module_id=module_id,
            hostname=hostname,
            gateway_hostname=gateway_hostname,
            sastoken=sastoken,
            server_verification_cert=server_verification_cert,
            **config_kwargs
        )
        pipeline_configuration.ensure_desired_properties = True

The kwargs parameter that can contain ensure_desired_properties parameter is processed but after that, the ensure_desired_properties parameter is set to True. So, it is not possible to set this parameter to False.

Do you have a solution for this issue?

@cartertinney cartertinney self-assigned this Nov 10, 2023
@cartertinney
Copy link
Member

@fhouge Good catch - not sure how this got overlooked - I'll work on implementing a solution as soon as I can

@cartertinney
Copy link
Member

Fixed in #1169 and will be included in the next release. Apologizes for the long delay

@cartertinney
Copy link
Member

azure-iot-device version 2.13.0 is available now. Will close this issue - if anything is not working as expected, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants