Ir para o conteúdo principal
Version: 4.x

Google Cloud Pub/Sub adapter

How it works

This adapter uses Google Cloud Pub/Sub service to forward messages between the nodes of a Socket.IO cluster.

The source code of this adapter can be found here.

Supported features 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


npm install


import { PubSub } from "@google-cloud/pubsub";
import { Server } from "";
import { createAdapter } from "";

const pubsub = new PubSub({
projectId: "your-project-id"

const topic = pubsub.topic(topicNameOrId);

const io = new Server({
adapter: createAdapter(topic)

// wait for the creation of the pub/sub subscription
await io.of("/").adapter.init();



NameDescriptionDefault value
subscriptionPrefixThe prefix for the new subscription to
subscriptionOptionsThe options used to create the subscription.-
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