使用IoT中心接收确认 [英] Receiving acknowledgements using IoT Hub

查看:85
本文介绍了使用IoT中心接收确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用DeviceClient时,我可以使用SendEvent发送消息,并使用SendBlob发送文件.但是我没有找到一种方法来确认Azure IoT中心已接收到消息/文件?

When using DeviceClient I can send messages using SendEvent and files using SendBlob. But I did not find a way to receive acknowledgement that messages/files have been received by Azure IoT Hub?

我发现解决此问题的唯一方法是使用serviceClient.GetFileNotificationReceiver(). 我是否想念某些东西?或者这是唯一的方法吗?

The only way I found to solve this is using serviceClient.GetFileNotificationReceiver(). Am I missing something or is this the only way?

另外,我似乎需要SharedAccessKeyName才能使用ServiceClient.但这在例如由DeviceExplorer创建的令牌(我用于DeviceClient).任何建议表示赞赏.

Also it seems I need SharedAccessKeyName to use ServiceClient. But this is not present in e.g. tokens created by DeviceExplorer (which I use for DeviceClient). Any advice is appreciated.

推荐答案

对于Java和C SDK,有

For Java and C sdks there are IotHubEventCallback and IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK but for C# there is no such interface implemented.

因此,对于C#,如果DeviceClient.SendEventAsync()成功发送一条消息而不会引发任何异常,否则它将失败.

So, for C#, a message will be sent successfully if DeviceClient.SendEventAsync() without throwing any exception, otherwise it fails.

或者您可以使用事件中心-兼容的端点,以监视IoT中心上的操作状态,D2C消息,文件上传...

Or you can utilize Event Hub-compatible endpoint to monitor the status of operations on your IoT hub, D2C message, file upload...

对于ServiceClient,您需要Azure IoT中心连接字符串,而不是设备连接字符串.您可以在设备资源管理器的配置"中找到它:

For ServiceClient, you need Azure IoT Hub connection string, not device connection string. You can find it in Configuration of Device Explorer:

这篇关于使用IoT中心接收确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆