Azure / azure-iot-cli-extension

Azure IoT extension for Azure CLI
Other
82 stars 65 forks source link

Device to Cloud messages not sent via azure cli commands #567

Closed learnquik closed 1 year ago

learnquik commented 2 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az iot device send-d2c-message Extension Name: azure-iot. Version: 0.14.0.

Errors:

The command failed with an unexpected error. Here is the traceback:

Traceback (most recent call last):
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\common\mqtt_transport.py", line 385, in connect
    rc = self._mqtt_client.connect(
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\paho\mqtt\client.py", line 914, in connect
    return self.reconnect()
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\paho\mqtt\client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\paho\mqtt\client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
  File "socket.py", line 808, in create_connection
  File "socket.py", line 796, in create_connection
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 658, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 692, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azext_iot\operations\hub.py", line 2251, in iot_device_send_message
    client_mqtt = mqtt_client(
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azext_iot\operations\_mqtt.py", line 32, in __init__
    self.device_client.on_message_received = self.message_handler
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\iothub\abstract_clients.py", line 671, in on_message_received
    self._generic_receive_handler_setter(
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\iothub\sync_clients.py", line 151, in _generic_receive_handler_setter
    self._enable_feature(feature_name)
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\iothub\sync_clients.py", line 107, in _enable_feature
    callback.wait_for_completion()
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\common\evented_callback.py", line 69, in wait_for_completion
    raise self.exception
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\common\pipeline\pipeline_stages_mqtt.py", line 189, in _run_op
    self.transport.connect(password=password)
  File "C:\Users\abhishek.kumar\.azure\cliextensions\azure-iot\azure\iot\device\common\mqtt_transport.py", line 413, in connect
    raise exceptions.ConnectionFailedError() from e
azure.iot.device.common.transport_exceptions.ConnectionFailedError

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.34.1

Extensions:
azure-iot 0.14.0

Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0

Additional Context

avagraw commented 2 years ago

@learnquik can you please provide additional information which will help me debug better. Specifically can you please provide:

  1. The data payload you are sending to the IoT Hub.
  2. The IoT Hub configuration you are using.
digimaun commented 2 years ago

I also noticed @learnquik , you are using azure-iot 0.14.0, one quick thing to try before getting into debugging is installing the latest version of the extension (currently 0.17.0). You can use az extension update --name azure-iot to do so.

digimaun commented 1 year ago

Closing due to lack of additional information we need to debug the issue. You can comment here and we can re-open if its still a problem.