0.1.0 • Published 2 months ago

@socket.io/aws-sqs-adapter v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Socket.IO AWS SQS adapter

The @socket.io/aws-sqs-adapter` package allows broadcasting packets between multiple Socket.IO servers.

Unlike the existing socket.io-sqs package, this package supports binary payloads and dynamic namespaces.

Table of contents

Supported features

Featuresocket.io versionSupport
Socket management4.0.0:white_check_mark: YES (since version 0.1.0)
Inter-server communication4.1.0:white_check_mark: YES (since version 0.1.0)
Broadcast with acknowledgements4.5.0:white_check_mark: YES (since version 0.1.0)
Connection state recovery4.6.0:x: NO

Installation

npm install @socket.io/aws-sqs-adapter

Usage

import { SNS } from "@aws-sdk/client-sns";
import { SQS } from "@aws-sdk/client-sqs";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/aws-sqs-adapter";

const snsClient = new SNS();
const sqsClient = new SQS();

const io = new Server({
  adapter: createAdapter(snsClient, sqsClient)
});

// wait for the creation of the SQS queue
await io.of("/").adapter.init();

io.listen(3000);

Options

NameDescriptionDefault value
topicNameThe name of the SNS topic.socket.io
topicTagsThe tags to apply to the new SNS topic.-
queuePrefixThe prefix of the SQS queue.socket.io
queueTagsThe tags to apply to the new SQS queue.-
heartbeatIntervalThe number of ms between two heartbeats.5_000
heartbeatTimeoutThe number of ms without heartbeat before we consider a node down.10_000

License

MIT