Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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:

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

like image 439
Jack Carlisle Avatar asked Feb 11 '16 16:02

Jack Carlisle


People also ask

What is MQTT over WebSocket?

MQTT over Websockets allows you to receive MQTT data directly into a web browser. This is important as the web browser may become the DE-facto interface for displaying MQTT data. MQTT websocket support for web browsers is provided by the JavaScript client.

What protocol does AWS IoT use?

AWS IoT Core supports standard communication protocols (HTTP, MQTT, and WebSockets and LoRaWAN are supported currently). Communication is secured using TLS. Processing data sent from connected devices.

Does AWS IoT use MQTT?

AWS IoT Core supports device connections that use the MQTT protocol and MQTT over WSS protocol and that are identified by a client ID. The AWS IoT Device SDKs support both protocols and are the recommended ways to connect devices to AWS IoT.

Which authentication method does AWS IoT core use for MQTT communication?

AWS IoT Core Now Supports MQTT Connections with Certificate Based Client Authentication On Port 443. Beginning today, you have more options to securely connect your devices to AWS IoT Core. You can use MQTT with certificate based client authentication on port 443.


1 Answers

Here's an example of how I'm opening the channel. I'm using Cognito unauth roles as a subscriber. I'm using the JS Paho client as well.

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

like image 103
Kyle Roche Avatar answered Oct 05 '22 13:10

Kyle Roche