Serverless Websocket
Serverless websocket support using AWS IOT & Cognito. Similar to other services like Pusher & ably.
This was designed primarily for the browser, but will also work in Node.js
The implementation is low-level and just covers getting the websocket URL. You'll probably want to use an MQTT client to connect to it.
Install
npm install serverless-websocket
Usage
const websocketURL = await // usage: you'll probably want to use a MQTT clientconst ws = websocketURL 'mqttv3.1'
How to
More coming soon, but for now you can refer to:
- https://github.com/kmamykin/aws-mqtt#aws-setup-and-security
- https://github.com/kmamykin/aws-mqtt/blob/master/src/createWebSocketStream.js
TODO
- Eliminate aws-signature-v4 dependency. This will allow us to use less of the crypto library.
- Simple MQTT client using https://github.com/mqttjs/mqtt-packet. Unfortunately, the MQTT clients are quite bloated in the browser, but the protocol is straightforward, so it wouldn't be hard to write a slim one on top of the standard websockets API.
Test
npm test
License
MIT