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
I'm trying to do module to module communication. I have 2 scripts receiver.py and sender.py for both of these I created a user like said here. However when I try to send messages to each other it does not work. The code itself does not give any errors and just finishes. however when looking at the iot-hub logs it shows behaviour that there is indeed something going wrong.
the route created to do the communication on is: FROM /messages/modules/msg_sender/outputs/* INTO BrokeredEndpoint("/modules/msg_receiver/inputs/test")
The credentials piece of code is just a class I created from the link I send converted to python, this just works since I can create the client.
Code sample exhibiting the issue
sender.py code (run with sudo -u sender /home/s360box/mini_hal/.venv/bin/python3 sending.py):
receiver.py code (run with sudo -u receiver /home/s360box/mini_hal/.venv/bin/python3 mqtt_recieving.py):
importasynciofromazure.iot.device.aioimportIoTHubModuleClientfromcredentialsimportAzureCredentialsasyncdefmessage_handler(message):
print(f"Received message on input", message)
asyncdefmain(device_sas_token):
client=IoTHubModuleClient.create_from_sastoken(device_sas_token, gateway_hostname="localhost")
awaitclient.connect()
print("Module connected to IoT Hub, waiting for messages on input...")
client.on_message_received=message_handlertry:
whileTrue:
awaitasyncio.sleep(10)
exceptasyncio.CancelledError:
passfinally:
awaitclient.disconnect()
print("Module disconnected.")
if__name__=="__main__":
device_sas_token=AzureCredentials().sas_stringloop=asyncio.get_event_loop()
res=loop.run_until_complete(main(device_sas_token))
Console log of the issue
python console with logging level to info:
INFO:azure.iot.device.common.mqtt_transport:Creating client for connecting using MQTT over TCP
INFO:azure.iot.device.iothub.aio.async_clients:Connecting to Hub...
INFO:azure.iot.device.common.mqtt_transport:Connect using port 8883 (TCP)
INFO:azure.iot.device.common.mqtt_transport:connected with result code: 0
INFO:azure.iot.device.common.pipeline.pipeline_stages_mqtt:_on_mqtt_connected called
INFO:azure.iot.device.iothub.abstract_clients:Connection State - Connected
INFO:azure.iot.device.iothub.aio.async_clients:Successfully connected to Hub
Module connected to IoT Hub.
Sending message to test: Hello from Module
INFO:azure.iot.device.iothub.aio.async_clients:Sending message to output:test...
INFO:azure.iot.device.common.mqtt_transport:publishing on devices/S360N2231205LNT7CZ/modules/msg-sender/messages/events/%24.on=test
INFO:azure.iot.device.common.mqtt_transport:payload published for 1
INFO:azure.iot.device.iothub.aio.async_clients:Successfully sent message to output: test
Message sent.
INFO:azure.iot.device.iothub.aio.async_clients:Disconnecting from Hub...
INFO:azure.iot.device.common.mqtt_transport:disconnecting MQTT client
INFO:azure.iot.device.common.mqtt_transport:disconnected with result code: 0
INFO:azure.iot.device.common.pipeline.pipeline_stages_mqtt:MQTTTransportStage: _on_mqtt_disconnect called
INFO:azure.iot.device.iothub.abstract_clients:Connection State - Disconnected
INFO:azure.iot.device.iothub.abstract_clients:Cleared all pending method requests due to disconnect
INFO:azure.iot.device.iothub.aio.async_clients:Successfully disconnected from Hub
Module disconnected.
IOT Logs where we can see an exception happen but its just -:
<6> 2024-03-04 14:28:44.330 +00:00 [INF] - Client S360N2231205LNT7CZ/msg-sender in device scope authenticated locally.
<6> 2024-03-04 14:28:44.331 +00:00 [INF] - Successfully generated identity for clientId S360N2231205LNT7CZ/msg-sender and username neu-n-iot-hub.azure-devices.net/S360N2231205LNT7CZ/msg-sender/?api-version=2019-10-01&DeviceClientType=azure-iot-device-iothub-py%2F2.12.0%283.6.9%3BLinux%20%238%20SMP%20PREEMPT%20Wed%20Dec%2013%2011%3A20%3A25%20CET%202023%3Baarch64%29
<6> 2024-03-04 14:28:44.331 +00:00 [INF] - "ClientAuthenticated, S360N2231205LNT7CZ/msg-sender, 496c72b8"
<6> 2024-03-04 14:28:44.332 +00:00 [INF] - New device connection for device S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:44.332 +00:00 [INF] - Client S360N2231205LNT7CZ/msg-sender connected to edgeHub, processing existing subscriptions.
<6> 2024-03-04 14:28:44.333 +00:00 [INF] - Bind device proxy for device S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:44.333 +00:00 [INF] - Binding message channel for device Id S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.350 +00:00 [INF] - "Closing connection for device: S360N2231205LNT7CZ/msg-sender, , "
<6> 2024-03-04 14:28:49.351 +00:00 [INF] - **Disposing MessagingServiceClient for device Id S360N2231205LNT7CZ/msg-sender because of exception -**
<6> 2024-03-04 14:28:49.351 +00:00 [INF] - Setting device proxy inactive for device Id S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.351 +00:00 [INF] - Removing device connection for device S360N2231205LNT7CZ/msg-sender with removeCloudConnection flag 'True'.
<6> 2024-03-04 14:28:49.355 +00:00 [INF] - Retrying cloud proxy operation SendMessageAsync for S360N2231205LNT7CZ/msg-sender.
<6> 2024-03-04 14:28:49.362 +00:00 [INF] - Attempting to connect to IoT Hub for client S360N2231205LNT7CZ/msg-sender via AMQP...
<6> 2024-03-04 14:28:49.446 +00:00 [INF] - Closing receiver in cloud proxy 929baa9d-961f-4963-bcad-30b1f259777c for S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.447 +00:00 [INF] - Closed cloud proxy 929baa9d-961f-4963-bcad-30b1f259777c for S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.447 +00:00 [INF] - Device connection removed for device S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.447 +00:00 [INF] - Remove device connection for device S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.518 +00:00 [INF] - Cloud connection for S360N2231205LNT7CZ/msg-sender is True
<6> 2024-03-04 14:28:49.518 +00:00 [INF] - Connection status for S360N2231205LNT7CZ/msg-sender changed to ConnectionEstablished
<6> 2024-03-04 14:28:49.518 +00:00 [INF] - Client S360N2231205LNT7CZ/msg-sender connected to cloud, processing existing subscriptions.
<6> 2024-03-04 14:28:49.519 +00:00 [INF] - Created cloud proxy for client S360N2231205LNT7CZ/msg-sender via AMQP, with client operation timeout 20 seconds.
<6> 2024-03-04 14:28:49.519 +00:00 [INF] - Initialized cloud proxy c1720fc9-8705-43e9-a275-89e8d4f7c367 for S360N2231205LNT7CZ/msg-sender
<6> 2024-03-04 14:28:49.519 +00:00 [INF] - Created cloud connection for client S360N2231205LNT7CZ/msg-sender
The text was updated successfully, but these errors were encountered:
Context
certifi (2024.2.2)
charset-normalizer (2.0.12)
deprecation (2.1.0)
idna (3.6)
janus (0.7.0)
mini-hal (0.1)
packaging (21.3)
paho-mqtt (1.6.1)
pip (9.0.1)
pkg-resources (0.0.0)
pyparsing (3.1.1)
PySocks (1.7.1)
requests (2.27.1)
requests-unixsocket (0.3.0)
setuptools (39.0.1)
typing-extensions (4.1.1)
Description of the issue
I'm trying to do module to module communication. I have 2 scripts
receiver.py
andsender.py
for both of these I created a user like said here. However when I try to send messages to each other it does not work. The code itself does not give any errors and just finishes. however when looking at the iot-hub logs it shows behaviour that there is indeed something going wrong.the route created to do the communication on is:
FROM /messages/modules/msg_sender/outputs/* INTO BrokeredEndpoint("/modules/msg_receiver/inputs/test")
The credentials piece of code is just a class I created from the link I send converted to python, this just works since I can create the client.
Code sample exhibiting the issue
sender.py code (run with
sudo -u sender /home/s360box/mini_hal/.venv/bin/python3 sending.py
):receiver.py code (run with
sudo -u receiver /home/s360box/mini_hal/.venv/bin/python3 mqtt_recieving.py
):Console log of the issue
python console with logging level to info:
IOT Logs where we can see an exception happen but its just
-
:The text was updated successfully, but these errors were encountered: