AWS SQS adapter

How it works

This adapter uses AWS Simple Queue Service to forward messages between the nodes of a Socket.IO cluster.

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

The source code of this adapter can be found here.

Supported features

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

Installation

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

Usage

  1. import { SNS } from "@aws-sdk/client-sns";
  2. import { SQS } from "@aws-sdk/client-sqs";
  3. import { Server } from "socket.io";
  4. import { createAdapter } from "@socket.io/aws-sqs-adapter";
  5. const snsClient = new SNS();
  6. const sqsClient = new SQS();
  7. const io = new Server({
  8. adapter: createAdapter(snsClient, sqsClient)
  9. });
  10. // wait for the creation of the SQS queue
  11. await io.of("/").adapter.init();
  12. 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

Latest releases

VersionRelease dateRelease notesDiff
0.1.0March 2024link-

Complete changelog