You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Edge agents halted sudo iotedge system stopthis sampleworks launched from the command line.
Tested by this command in cloudshell: az iot hub invoke-device-method --device-id "Alpha" --hub-name "hub2" --method-name "method1"
With the Edge agent restored (either reboot or sudo iotedge config apply -c '/etc/aziot/config.toml'), similar code based on this sample never triggers the on_method_request_received call_back.
There are no errors in the logs, however the cloudshell command fails with Error occurred in request., ReadTimeout: HTTPSConnectionPool(host='edge2.azure-devices.net', port=443): Read timed out. (read timeout=30)
There are no errors in sudo iotedge check --verbose
The container successfully writes to the logs - which correctly show in Azure Portal "Troubleshooting'.
Command used to create the container: sudo docker build --rm -f "./modules/App/Dockerfile.arm64v8" -t iotedge.azurecr.io/app:2023.10.12.16.10-arm64 "./modules/App/"
import asyncio
import sys
import signal
import threading
from azure.iot.device.aio import IoTHubModuleClient
from datetime import datetime
# Event indicating client stop
stop_event = threading.Event()
def create_client():
client = IoTHubModuleClient.create_from_edge_environment()
# Define behavior for receiving methods
async def method_handler(method_request):
print("method request received: {}".format(method_request.name))
method_response = MethodResponse.create_from_method_request(method_request, 400, None)
await client.send_method_response(method_response)
# set the received data handlers on the client
client.on_method_request_received = method_handler
return client
async def run_sample(client):
await client.connect()
while not stop_event.is_set():
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print(current_time, " heartbeat")
await asyncio.sleep(15)
def main():
if not sys.version >= "3.5.3":
raise Exception( "The sample requires python 3.5.3+. Current version of Python: %s" % sys.version )
print ( "IoT Hub Client for Python" )
# NOTE: Client is implicitly connected due to the handler being set on it
client = create_client()
# Define a handler to cleanup when module is is terminated by Edge
def module_termination_handler(signal, frame):
print ("IoTHubClient sample stopped by Edge")
stop_event.set()
# Set the Edge termination handler
signal.signal(signal.SIGTERM, module_termination_handler)
# Run the sample
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(run_sample(client))
except Exception as e:
print("Unexpected error %s " % e)
raise
finally:
print("Shutting down IoT Hub Client...")
loop.run_until_complete(client.shutdown())
loop.close()
if __name__ == "__main__":
main()
Console log of the issue
No error in the log
The text was updated successfully, but these errors were encountered:
Context
Raspberry Pi4B
Linux RPi4-Alpha 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
iotedge 1.4.16
Python 3.9.2
pip 23.2.1 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9)
Description of the issue
With Edge agents halted
sudo iotedge system stop
this sample works launched from the command line.Tested by this command in cloudshell:
az iot hub invoke-device-method --device-id "Alpha" --hub-name "hub2" --method-name "method1"
With the Edge agent restored (either reboot or
sudo iotedge config apply -c '/etc/aziot/config.toml'
), similar code based on this sample never triggers the on_method_request_received call_back.There are no errors in the logs, however the cloudshell command fails with
Error occurred in request., ReadTimeout: HTTPSConnectionPool(host='edge2.azure-devices.net', port=443): Read timed out. (read timeout=30)
There are no errors in
sudo iotedge check --verbose
The container successfully writes to the logs - which correctly show in Azure Portal "Troubleshooting'.
Command used to create the container:
sudo docker build --rm -f "./modules/App/Dockerfile.arm64v8" -t iotedge.azurecr.io/app:2023.10.12.16.10-arm64 "./modules/App/"
Code sample exhibiting the issue
A simplification of this sample
Console log of the issue
No error in the log
The text was updated successfully, but these errors were encountered: