/cbsignal_node

High performance CDNBye signaling service

Primary LanguageTypeScriptApache License 2.0Apache-2.0

About

High performance CDNBye signaling service written in node.js

Features

  • handles more than 40k WebSocket Secure (HTTPS) peers on a VPS with only 2 GiB memory and 1 virtual CPU thanks to uWebSockets.js I/O backend and perfomance optimizations in the code
  • handles ws:// (HTTP) and wss:// (HTTPS) connections simultaneously
  • IPv4 and IPv6 support
  • robust and well-tested: CI, unit tests, static code analyzis, 100% TypeScript
  • statistics under /info URL

Related projects

  • cbsignal - High performance CDNBye signaling service written in golang

Build instructions

Node.js 10+ is required.

yarn install
yarn run compile

Run instructions

./bin/cbsignal [config.json]

or

node dist/run-uws-signal.js [config.json]

or

yarn start [config.json]

Configuration

See sample

Name Type Description
servers.websockets.path string URL pattern for the WebSockets endpoint
servers.websockets.maxPayloadLength number The maximum length of received message
servers.websockets.compression boolean false = DISABLED, true = SHARED_COMPRESSOR (see details)
servers.websockets.maxConnections number The maximum number of WebSocket connections. 0 = no limit.

Run on Debug Mode

DEBUG="*" node ./dist/run-uws-signal.js config.json

Run with Daemon

sudo yarn install pm2 -g
pm2 start pm2.config.js

Run by Docker

sudo docker run --name signal --net host  --restart=on-failure:3 -d cdnbye/cbsignal_node:latest

Run by Docker with your own Config

mkdir config && cd config
touch config.json

Then cony your config to config.json, you can copy your SSL cert to this directory, then:

sudo docker run --name cbsignal_node --net host  --restart=unless-stopped  -d -v "$(pwd)"/config:/cbsignal/config  cdnbye/cbsignal_node:latest

You can check the logs by run:

sudo docker logs cbsignal_node