Websocket all-to-all connectivity cluster

Usage no npm install needed!

<script type="module">
  import cfwarePeerCluster from 'https://cdn.skypack.dev/@cfware/peer-cluster';



Travis CI Greenkeeper badge NPM Version NPM Downloads MIT

Websocket all-to-all connectivity cluster.

Install @cfware/peer-cluster

This module requires node.js 12 or above with support for ESM modules. This has only been tested/used with esm.

npm i --save esm @cfware/peer-cluster


import {createServer} from 'http';

import pEvent from 'p-event';
import {PeerCluster} from '@cfware/peer-cluster';

(async () => {
    const httpd = createServer();
    await pEvent(httpd, 'listening');

    const peerCluster = new PeerCluster({
        peerId: 'server1',
        origin: `ws://localhost:${httpd.address().port}/`,
        respond404: true

    httpd.on('upgrade', (req, sock, head) => {
        cluster.tryUpgrade(req, sock, head);

Running tests

Tests are provided by xo and ava.

npm install
npm test