Azure IoT Hub : Cloud to Device messaging using MQTT and SDK












0















Microsoft has its own SDK for interacting with IoT Hub (Microsoft.Azure.Devices)
It features a client called ServiceClient that as I understand it is client you are supposed to use when sending messages from your backend to a device through IoT hub.



When initializing the ServiceClient like below the only supported TransportTypes are Amqp and Amqp_websockets_only. My devices only support MQTT. How should I go about that?



public async Task SendMessage()
{
var serviceClient = ServiceClient.CreateFromConnectionString("", TransportType.Amqp);
var commandMessage = new Message(Encoding.ASCII.GetBytes("Cloud to device message."));
await serviceClient.SendAsync("myFirstDevice", commandMessage);
}



According to the c2d guidelines "all protocols" are supported.



I have read through this documentation, but it only documents device to cloud, not cloud to device.



Looking at the SDK documentation it only lists AMQP for key features under device-to-cloud










share|improve this question

























  • Are you sure this feature is related to the device-to-cloud messaging?

    – Roman Kiss
    Nov 14 '18 at 9:32











  • I am not sure about anything. This is new territory for me.

    – WPFUser
    Nov 14 '18 at 9:38











  • OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

    – Roman Kiss
    Nov 14 '18 at 9:46
















0















Microsoft has its own SDK for interacting with IoT Hub (Microsoft.Azure.Devices)
It features a client called ServiceClient that as I understand it is client you are supposed to use when sending messages from your backend to a device through IoT hub.



When initializing the ServiceClient like below the only supported TransportTypes are Amqp and Amqp_websockets_only. My devices only support MQTT. How should I go about that?



public async Task SendMessage()
{
var serviceClient = ServiceClient.CreateFromConnectionString("", TransportType.Amqp);
var commandMessage = new Message(Encoding.ASCII.GetBytes("Cloud to device message."));
await serviceClient.SendAsync("myFirstDevice", commandMessage);
}



According to the c2d guidelines "all protocols" are supported.



I have read through this documentation, but it only documents device to cloud, not cloud to device.



Looking at the SDK documentation it only lists AMQP for key features under device-to-cloud










share|improve this question

























  • Are you sure this feature is related to the device-to-cloud messaging?

    – Roman Kiss
    Nov 14 '18 at 9:32











  • I am not sure about anything. This is new territory for me.

    – WPFUser
    Nov 14 '18 at 9:38











  • OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

    – Roman Kiss
    Nov 14 '18 at 9:46














0












0








0








Microsoft has its own SDK for interacting with IoT Hub (Microsoft.Azure.Devices)
It features a client called ServiceClient that as I understand it is client you are supposed to use when sending messages from your backend to a device through IoT hub.



When initializing the ServiceClient like below the only supported TransportTypes are Amqp and Amqp_websockets_only. My devices only support MQTT. How should I go about that?



public async Task SendMessage()
{
var serviceClient = ServiceClient.CreateFromConnectionString("", TransportType.Amqp);
var commandMessage = new Message(Encoding.ASCII.GetBytes("Cloud to device message."));
await serviceClient.SendAsync("myFirstDevice", commandMessage);
}



According to the c2d guidelines "all protocols" are supported.



I have read through this documentation, but it only documents device to cloud, not cloud to device.



Looking at the SDK documentation it only lists AMQP for key features under device-to-cloud










share|improve this question
















Microsoft has its own SDK for interacting with IoT Hub (Microsoft.Azure.Devices)
It features a client called ServiceClient that as I understand it is client you are supposed to use when sending messages from your backend to a device through IoT hub.



When initializing the ServiceClient like below the only supported TransportTypes are Amqp and Amqp_websockets_only. My devices only support MQTT. How should I go about that?



public async Task SendMessage()
{
var serviceClient = ServiceClient.CreateFromConnectionString("", TransportType.Amqp);
var commandMessage = new Message(Encoding.ASCII.GetBytes("Cloud to device message."));
await serviceClient.SendAsync("myFirstDevice", commandMessage);
}



According to the c2d guidelines "all protocols" are supported.



I have read through this documentation, but it only documents device to cloud, not cloud to device.



Looking at the SDK documentation it only lists AMQP for key features under device-to-cloud







azure azure-iot-hub






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:53







WPFUser

















asked Nov 14 '18 at 8:37









WPFUserWPFUser

7810




7810













  • Are you sure this feature is related to the device-to-cloud messaging?

    – Roman Kiss
    Nov 14 '18 at 9:32











  • I am not sure about anything. This is new territory for me.

    – WPFUser
    Nov 14 '18 at 9:38











  • OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

    – Roman Kiss
    Nov 14 '18 at 9:46



















  • Are you sure this feature is related to the device-to-cloud messaging?

    – Roman Kiss
    Nov 14 '18 at 9:32











  • I am not sure about anything. This is new territory for me.

    – WPFUser
    Nov 14 '18 at 9:38











  • OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

    – Roman Kiss
    Nov 14 '18 at 9:46

















Are you sure this feature is related to the device-to-cloud messaging?

– Roman Kiss
Nov 14 '18 at 9:32





Are you sure this feature is related to the device-to-cloud messaging?

– Roman Kiss
Nov 14 '18 at 9:32













I am not sure about anything. This is new territory for me.

– WPFUser
Nov 14 '18 at 9:38





I am not sure about anything. This is new territory for me.

– WPFUser
Nov 14 '18 at 9:38













OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

– Roman Kiss
Nov 14 '18 at 9:46





OK, the table in this document shows a Cloud-to-device messaging and protocol AMQP and AMQP-WS for your backend app. That's correct. The backend communicated to the devices via the Azure IoT Hub (service-facing endpoint) and using only AMQP and AMQP-WS protocols, but the Azure IoT Hub communicated with a device (device-facing endpoint) via a connected device protocol such as MQTT, AMQP or Https.

– Roman Kiss
Nov 14 '18 at 9:46












1 Answer
1






active

oldest

votes


















2














For device-to-cloud messaging, the device can use the MQTT, MQTT-WS, AMQP, AMQP-WS, or HTTP protocols. See the IoT Hub device SDK key features. A device communicates with IoT Hub for both d2c and c2d using the Microsoft Azure IoT device SDK for .NET. Note that there are also device SDKs available for Java, Node, Python and C.



If you have a back-end application that needs to send a c2d message to a device, then that back-end application should use one of the Azure IoT service SDKs such as
Microsoft Azure IoT service SDK for C# to connect to IoT Hub and send the c2d message. The back-end application must use AMQP or AMQP-WS.



The protocol used by the device to connect to IoT Hub is independent of the protocol used by the back-end application to connect to IoT Hub. For example, a back-end application could connect to IoT Hub using AMQP to send a c2d message to a device that's connected to the hub using MQTT.






share|improve this answer
























  • Thank you! Makes sense!

    – WPFUser
    Nov 14 '18 at 22:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295980%2fazure-iot-hub-cloud-to-device-messaging-using-mqtt-and-sdk%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














For device-to-cloud messaging, the device can use the MQTT, MQTT-WS, AMQP, AMQP-WS, or HTTP protocols. See the IoT Hub device SDK key features. A device communicates with IoT Hub for both d2c and c2d using the Microsoft Azure IoT device SDK for .NET. Note that there are also device SDKs available for Java, Node, Python and C.



If you have a back-end application that needs to send a c2d message to a device, then that back-end application should use one of the Azure IoT service SDKs such as
Microsoft Azure IoT service SDK for C# to connect to IoT Hub and send the c2d message. The back-end application must use AMQP or AMQP-WS.



The protocol used by the device to connect to IoT Hub is independent of the protocol used by the back-end application to connect to IoT Hub. For example, a back-end application could connect to IoT Hub using AMQP to send a c2d message to a device that's connected to the hub using MQTT.






share|improve this answer
























  • Thank you! Makes sense!

    – WPFUser
    Nov 14 '18 at 22:48
















2














For device-to-cloud messaging, the device can use the MQTT, MQTT-WS, AMQP, AMQP-WS, or HTTP protocols. See the IoT Hub device SDK key features. A device communicates with IoT Hub for both d2c and c2d using the Microsoft Azure IoT device SDK for .NET. Note that there are also device SDKs available for Java, Node, Python and C.



If you have a back-end application that needs to send a c2d message to a device, then that back-end application should use one of the Azure IoT service SDKs such as
Microsoft Azure IoT service SDK for C# to connect to IoT Hub and send the c2d message. The back-end application must use AMQP or AMQP-WS.



The protocol used by the device to connect to IoT Hub is independent of the protocol used by the back-end application to connect to IoT Hub. For example, a back-end application could connect to IoT Hub using AMQP to send a c2d message to a device that's connected to the hub using MQTT.






share|improve this answer
























  • Thank you! Makes sense!

    – WPFUser
    Nov 14 '18 at 22:48














2












2








2







For device-to-cloud messaging, the device can use the MQTT, MQTT-WS, AMQP, AMQP-WS, or HTTP protocols. See the IoT Hub device SDK key features. A device communicates with IoT Hub for both d2c and c2d using the Microsoft Azure IoT device SDK for .NET. Note that there are also device SDKs available for Java, Node, Python and C.



If you have a back-end application that needs to send a c2d message to a device, then that back-end application should use one of the Azure IoT service SDKs such as
Microsoft Azure IoT service SDK for C# to connect to IoT Hub and send the c2d message. The back-end application must use AMQP or AMQP-WS.



The protocol used by the device to connect to IoT Hub is independent of the protocol used by the back-end application to connect to IoT Hub. For example, a back-end application could connect to IoT Hub using AMQP to send a c2d message to a device that's connected to the hub using MQTT.






share|improve this answer













For device-to-cloud messaging, the device can use the MQTT, MQTT-WS, AMQP, AMQP-WS, or HTTP protocols. See the IoT Hub device SDK key features. A device communicates with IoT Hub for both d2c and c2d using the Microsoft Azure IoT device SDK for .NET. Note that there are also device SDKs available for Java, Node, Python and C.



If you have a back-end application that needs to send a c2d message to a device, then that back-end application should use one of the Azure IoT service SDKs such as
Microsoft Azure IoT service SDK for C# to connect to IoT Hub and send the c2d message. The back-end application must use AMQP or AMQP-WS.



The protocol used by the device to connect to IoT Hub is independent of the protocol used by the back-end application to connect to IoT Hub. For example, a back-end application could connect to IoT Hub using AMQP to send a c2d message to a device that's connected to the hub using MQTT.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 12:31









Dominic BettsDominic Betts

1,7201410




1,7201410













  • Thank you! Makes sense!

    – WPFUser
    Nov 14 '18 at 22:48



















  • Thank you! Makes sense!

    – WPFUser
    Nov 14 '18 at 22:48

















Thank you! Makes sense!

– WPFUser
Nov 14 '18 at 22:48





Thank you! Makes sense!

– WPFUser
Nov 14 '18 at 22:48




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295980%2fazure-iot-hub-cloud-to-device-messaging-using-mqtt-and-sdk%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values