Azure topic and sending message over MQTT

Multi tool use
Azure topic and sending message over MQTT
Is it possible to send messages to azure to any custom topic via mqtt. All example that I've found so far work with standard topics
'devices/' + hubName + '/messages/events/'
'devices/' + hubName + '/messages/devicebound/#'
Btw, I tried to send/subscribe on the topic/subscription above with MQTT.fx application and never received messages, although the connection was successful.
MQTT.fx being subscribed on devices/mydevice/messages/devicebound/#, never received messages sent from MQTT.fx to devices/mydevice/messages/events/ (I use the application as sender and receiver). Connection is established (green light turned on)
– amplifier
Jul 2 at 12:57
2 Answers
2
Did you have a look on these ??
Azure IoT Hub - Send message (C2D) to one device on 2 topics instead of devicebound/#
Can I send a message to a group of Azure IoT Hub Devices connected via MQTT WebSocket?
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-c2d-guidance
Currently I'm trying to send device-to-cloud-messages
– amplifier
Jul 2 at 11:43
The topic filter of devices/{device_id}/messages/devicebound/#
is to subscribe receiving message from IoT Hub(Cloud-To-Device message), it think you need to understand the difference about device-to-cloud message and cloud-to-device message from here.
The topic of devices/{device_id}/messages/events/
is for sending a device-to-cloud message from device.
devices/{device_id}/messages/devicebound/#
devices/{device_id}/messages/events/
You can use Device Explorer to test this issue. When you send a message to device with the tool, MQTT.fx will receive the message.
Thank you for clarification on MQTT.fx. Yesterday I was able to send messages to devices/{device_id}/messages/events/ from Python source code (using paho.mqtt). As a reference I used code from github.com/gloveboxes/Azure-IoT-Hub-with-Python-and-MQTT/blob/…. Now I need to publish to custom topic. I've created endpoint, assigned to topic, and route for the endpoint. But I'm not able to publish. Which url should I use? Thanks!
– amplifier
Jul 3 at 9:49
@amplifier, IoT Hub is not a general-purpose pub-sub messaging broker, it only supports the documented topic names and topic filters, but not supports custom topic. More information please see this document.
– Michael Xu - MSFT
Jul 4 at 1:36
Finally I did it use routing. Take a look here please stackoverflow.com/questions/51160000/…
– amplifier
Jul 4 at 8:56
@amplifier, i have looked the thread you mentioned. In this thread the topicName is not a custom topic filter for IoT Hub,
$.ct=application%2Fjson&$.ce=utf-8
is just parameter. I am confused about what is the relation with custom topic
and route message to an endpoint in above comment?– Michael Xu - MSFT
Jul 4 at 9:17
$.ct=application%2Fjson&$.ce=utf-8
custom topic
@amplifier, in addition to above comment. To some extent, you can refer to the the topic name with device id as a custom topic. But in fact, it is different with the custom topic for mqtt broker.
– Michael Xu - MSFT
Jul 5 at 3:21
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What did you mean about 'never received messages'? Did it mean that the back end can not receive the messages which sent from MQTT.fx(Device-To-Cloud), or MQTT.fx can not receive the messages which sent from service(Cloud-To-Device)?
– Michael Xu - MSFT
Jul 2 at 6:11