Azure Service Bus adapter

How it works

This adapter uses Azure Service Bus service to forward messages between the nodes of a Socket.IO cluster.

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/azure-service-bus-adapter

Usage

  1. import { ServiceBusClient, ServiceBusAdministrationClient } from "@azure/service-bus";
  2. import { Server } from "socket.io";
  3. import { createAdapter } from "@socket.io/azure-service-bus-adapter";
  4. const connectionString = "Endpoint=...";
  5. const serviceBusClient = new ServiceBusClient(connectionString);
  6. const serviceBusAdminClient = new ServiceBusAdministrationClient(connectionString);
  7. const io = new Server({
  8. adapter: createAdapter(serviceBusClient, serviceBusAdminClient)
  9. });
  10. // wait for the creation of the subscription
  11. await io.of("/").adapter.init();
  12. io.listen(3000);

Options

NameDescriptionDefault value
topicNameThe name of the topic.socket.io
topicOptionsThe options used to create the topic.-
subscriptionPrefixThe prefix of the subscription (one subscription will be created per Socket.IO server in the cluster).socket.io
receiverOptionsThe options used to create the subscription.-
topicOptionsThe options used to create the receiver.-
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