简体   繁体   English

使用 Java 向 IoT 中心发送 C2D 消息

[英]C2D messages to IoT Hub with Java

Is there any possibility to send Cloud2Device message to an IoT Hub with Java by using MQTT as protocol?是否有可能通过使用 MQTT 作为协议将 Cloud2Device 消息发送到 Java 的 IoT 中心?

I use ServiceClient from library: https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/ServiceClient.java and there it's impossible using MQTT, only AMQPS.我使用库中的 ServiceClient: https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/ iot/service/ServiceClient.java并且不可能使用 MQTT,只能使用 AMQPS。

You can receive Cloud2Device messages on your device, using the Device SDK , if you are connected over MQTT, AMQP or HTTPS.如果您通过 MQTT、AMQP 或 HTTPS 连接,您可以使用设备 SDK在您的设备上接收 Cloud2Device 消息。

In order to connect to your IoTHub from your solution back end, using the Service SDK to send cloud-to-device messages to a single device you will need to use AMQP or AMQP over Websockets.为了从您的解决方案后端连接到您的 IoTHub,使用服务 SDK将云到设备的消息发送到单个设备,您需要使用 AMQP 或 AMQP over Websockets。

在此处输入图像描述

Service endpoints.服务端点。 Each IoT hub exposes a set of endpoints for your solution back end to communicate with your devices.每个 IoT 中心都会为您的解决方案后端公开一组端点,以便与您的设备进行通信。 With one exception, these endpoints are only exposed using the AMQP and AMQP over WebSockets protocols.除了一个例外,这些端点仅使用 AMQP 和 AMQP over WebSockets 协议公开。

Ref: Reference - IoT Hub endpoints参考: 参考 - IoT 中心端点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM