Message properties seem to get lost after routing through edgeHub
See original GitHub issue-
OS and version used: Debian Stretch on leaf device, Raspbian stretch on edge gateway
-
Python runtime used: 3.5.3
-
SDK version used: 1.4.3
-
IoT Edge version used: 1.0.4
Description of the issue:
I’m running a Raspberry Pi as a transparent IoT Edge Gateway with two custom modules in addition to the edgeAgent and edgeHub. The edgeHub is configured to route the messages coming from leaf device to one of the custom module with the route below.
"FROM /messages/* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/camera-capture/inputs/input1\")"
In the module I added a function which listens for incoming messages on input1 and I can see the messages and print the message body. In the leaf device application I’m sending messages via MQTT with application properties (see code snippet 1). When I change the route to…
"FROM /messages/* WHERE (CameraState = 'true') INTO BrokeredEndpoint(\"/modules/camera-capture/inputs/input1\")"
…only half of the messages are routed to the module which indicates that the property is found by the edgeHub and interpreted correctly. However, when I try to extract the properties of the message in the CameraCapture module (see code snippet 2) they seem to be empty (see console output).
So it seems like the message properties are getting lost after routing through the edge hub. Also same result using AMQP.
Code sample exhibiting the issue:
Code snippet 1 (sending message):
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
set_certificates(client)
message = IoTHubMessage("test message")
# send a message every two seconds
while True:
# add custom application properties
prop_map = message.properties()
if run_camera:
prop_map.add_or_update("CameraState", "true")
else:
prop_map.add_or_update("CameraState", "false")
client.send_event_async(message, send_confirmation_callback, None)
print("Message transmitted to IoT Edge")
time.sleep(2)
Code snippet 2 (receiving message):
def receive_message_callback(message, hubManager):
global RECEIVE_CALLBACKS
message_buffer = message.get_bytearray()
size = len(message_buffer)
print ( "Message received: %s" % message_buffer[:size].decode('utf-8'))
map_properties = message.properties()
key_value_pair = map_properties.get_internals()
print ("Key value pair: %s" % key_value_pair)
return IoTHubMessageDispositionResult.ACCEPTED
Console log of the issue:
Message received: test message
Key value pair: {}
Waiting...
Waiting...
Message received: test message
Key value pair: {}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@MaWa19 thanks for filing this issue and sorry for the delay in triaging it. I’ll look into it ASAP.
@MaWa19, @sense2k8, @darthkurak, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey