来自物联网中心的消息数据未到达Web应用程序 [英] Message data from iot hub not arriving at web app

查看:103
本文介绍了来自物联网中心的消息数据未到达Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我成功尝试了此示例:

https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-hub/iot-hub-live-data-visualization-in-web-apps.md

它工作正常,我可以在Web App控制台中看到消息.我用raspberry-pi-web-simulator进行了测试.

现在,我想使用现有的物联网中心来实现此解决方案.物联网中心已经具有为消息路由定义的路由和StreamAnalytics的使用者组.现在我有一个问题,就是什么都没有到达我的我们的应用程序.我不知道为什么会这样.

在中心中设置了消费者组,并在Web应用程序中设置了连接字符串.我要使用的集线器中的物联网设备具有不同的消息正文,但我想那应该不是问题.

有想法或类似经验的人吗?

干杯
尼尔斯

解决方案

你好,

您的设备发送的消息应采用与树莓派设备相同的结构:

https://github.com/Azure -Samples/iot-hub-node-raspberrypi-client-app/blob/master/index.js

https://github.com/Azure -Samples/iot-hub-node-raspberrypi-client-app/blob/master/messageProcessor.js

 cb(JSON.stringify({
      messageId:messageId,
      deviceId:this.deviceId,
      温度:数据.温度,
      湿度:数据湿度
    }),data.temperature> this.temperatureAlert); 

还应包含属性'temperatureAlert'

 var message =新消息(内容);
    message.properties.add('temperatureAlert',temperatureAlert?'true':'false'); 

这是使用来确认是否正在IoTHub上接收消息. Visual Studio代码扩展&Azure IoT工具包

如果此答案有帮助,请单击标记为答案"或投票.要提供有关您的论坛体验的其他反馈,请单击 /p>

解决方案

Hello ,

The messages sent by your device should follow the same structure as the raspberry pi device: 

https://github.com/Azure-Samples/iot-hub-node-raspberrypi-client-app/blob/master/index.js

https://github.com/Azure-Samples/iot-hub-node-raspberrypi-client-app/blob/master/messageProcessor.js

cb(JSON.stringify({
      messageId: messageId,
      deviceId: this.deviceId,
      temperature: data.temperature,
      humidity: data.humidity
    }), data.temperature > this.temperatureAlert);

It should also include the property 'temperatureAlert'

var message = new Message(content);
    message.properties.add('temperatureAlert', temperatureAlert ? 'true' : 'false');

That is the only way you can visualize data using this sample without any modifications.

PS: You should also confirm if you are receiving messages on IoTHub using Visual Studio Code Extension Azure IoT Toolkit

==========================================================

If this answer was helpful, click "Mark as Answer" or Up-Vote. To provide additional feedback on your forum experience, click here


这篇关于来自物联网中心的消息数据未到达Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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