简体   繁体   English

通过 websocket 连接 AWS MQTT

[英]Connecting AWS MQTT via websocket

I am trying to connect a sensor to an AWS MQTT Broker to a database that will send it to a webserver so that it can be easily accessible.我正在尝试将传感器连接到 AWS MQTT 代理和数据库,该数据库将其发送到网络服务器,以便可以轻松访问。 Right now the only way people in our lab can have access to our sensor data is through contacting me directly and having me connect to the Node Red dashboard.目前,我们实验室中的人员可以访问我们的传感器数据的唯一方法是直接与我联系并让我连接到 Node Red 仪表板。 Would there be any way for everyone to have access to the data via WebSocket, or at least a couple of people?每个人或至少几个人都可以通过 WebSocket 访问数据吗?

I've searched for hours on end and have had no success regarding the ease of accessibility.我已经连续搜索了几个小时,但在可访问性方面没有取得成功。

From what I've researched there is this a java based client called MQTT.Cool that can connect multiple brokers and have data published via WebSocket using JavaScript.根据我的研究,这是一个名为 MQTT.Cool 的基于 Java 的客户端,它可以连接多个代理并使用 JavaScript 通过 WebSocket 发布数据。 However there is literally no data available except the ones provided by the company.然而,除了公司提供的数据外,实际上没有可用的数据。 So combining it it with my project has not been an easy task.所以将它与我的项目结合起来并不是一件容易的事。

Also, I've thought about allowing my node red dashboard to be accessed out of my local ip-address, but due to security reasons it has been recommended not to be done.此外,我还考虑过允许从我的本地 IP 地址访问我的节点红色仪表板,但由于安全原因,建议不要这样做。

AWS IoT provides an SDK that you can use in your browser: https://github.com/aws/aws-iot-device-sdk-js#browser AWS IoT 提供了一个可以在浏览器中使用的开发工具包: https : //github.com/aws/aws-iot-device-sdk-js#browser

You can write a web application and view the contents returned by the database after logging in If you need to browse in real-time, you can use mqtt.js to subscribe to some topics: https://www.emqx.com/en/blog/connect-to-mqtt-broker-with-websocket可以写一个web应用,登录后查看数据库返回的内容如果需要实时浏览,可以使用mqtt.js订阅一些主题: https ://www.emqx.com/en /blog/connect-to-mqtt-broker-with-websocket

Or use MQTTX, a client tool, to connect directly to the MQTT broker and subscribe to topic或者使用客户端工具 MQTTX 直接连接到 MQTT 代理并订阅主题

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

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