Giter VIP home page Giter VIP logo

socket.io-aws-sqs-adapter's Introduction

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

Feature socket.io version Support
Socket management 4.0.0 ✅ YES (since version 0.1.0)
Inter-server communication 4.1.0 ✅ YES (since version 0.1.0)
Broadcast with acknowledgements 4.5.0 ✅ YES (since version 0.1.0)
Connection state recovery 4.6.0 ❌ 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

Name Description Default value
topicName The name of the SNS topic. socket.io
topicTags The tags to apply to the new SNS topic. -
queuePrefix The prefix of the SQS queue. socket.io
queueTags The tags to apply to the new SQS queue. -
heartbeatInterval The number of ms between two heartbeats. 5_000
heartbeatTimeout The number of ms without heartbeat before we consider a node down. 10_000

License

MIT

socket.io-aws-sqs-adapter's People

Contributors

darrachequesne avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

socket.io-aws-sqs-adapter's Issues

There is no default value for opts in createAdapter

So I was trying to use createAdapter function based on documentation example and it errored out with this error.

const topicName = opts.topicName || "socket-io";
                           ^
TypeError: Cannot read properties of undefined (reading 'topicName')

Basically if you do not provide options object it will be undefined. Maybe it will be better to rewrite like this

const topicName = opts?.topicName ?? "socket-io";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.