简体   繁体   English

AWS IoT MQTT over WebSocket协议

[英]AWS IoT MQTT over WebSocket Protocol

I've been following the AWS IoT docs trying to get started with the MQTT tutorial at http://docs.aws.amazon.com/iot/latest/developerguide/protocols.html#mqtt-ws to set up a WebSocket connection to AWS IoT in a web application. 我一直在关注AWS IoT文档试图开始使用http://docs.aws.amazon.com/iot/latest/developerguide/protocols.html#mqtt-ws上的MQTT教程来设置WebSocket连接到Web应用程序中的AWS IoT。 The first step is to initiate a WebSocket connection by making a GET request to an endpoint created by following the steps in the tutorial but I'm getting this error: 第一步是通过对通过遵循教程中的步骤创建的端点发出GET请求来启动WebSocket连接,但是我收到此错误:

XMLHttpRequest cannot load <my endpoint> Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

I was wondering if anyone has encountered this error and if so, how they resolved it? 我想知道是否有人遇到过这个错误,如果有的话,他们是如何解决的?

Here's a link to the code https://github.com/dwyl/learn-aws-iot/blob/2c8035728ec8228e296580c8714f3f7ace870fbe/src/js/components/App.js 这是代码的链接https://github.com/dwyl/learn-aws-iot/blob/2c8035728ec8228e296580c8714f3f7ace870fbe/src/js/components/App.js

Here's an example of how I'm opening the channel. 这是我如何打开频道的一个例子。 I'm using Cognito unauth roles as a subscriber. 我使用Cognito unauth角色作为订阅者。 I'm using the JS Paho client as well. 我也在使用JS Paho客户端。

http://draw.kyleroche.com/main.js http://draw.kyleroche.com/main.js

AWS Labs还在此处发布了一个基于WebSockets参考示例的MQTT: https//github.com/awslabs/aws-iot-examples

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

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