RTCMultiConnection Socket.io Server
RTCMultiConnection Socket.io Server (npm package `rtcmulticonnection-server`) is a server-side component designed to facilitate real-time communication using WebRTC, specifically for the RTCMultiConnection client-side library. Its primary function is to manage signaling over a Socket.io connection, enabling peers to discover each other and exchange necessary session descriptions and ICE candidates to establish peer-to-peer WebRTC connections. The current stable version is 1.3.3, though the most significant feature change occurred in version 1.3.1. This package does not follow a strict, frequent release cadence, with major updates appearing intermittently as needed to support the core RTCMultiConnection library. A key differentiator since version 1.3.1 is its shift from being an independent server application to a modular component that integrates seamlessly into existing Node.js applications that already utilize Socket.io. This design choice allows developers greater flexibility in incorporating WebRTC signaling into their custom server architectures, rather than being forced into a standalone solution. It specifically avoids creating its own HTTP or Socket.io servers, delegating that responsibility to the host application.
Common errors
-
TypeError: RTCMultiConnectionServer.addSocket is not a function
cause Attempting to call `addSocket` on a `socket.io` instance or an incorrect object, or the module was not imported correctly.fixEnsure `RTCMultiConnectionServer` is correctly `require`d and you are calling `addSocket` as `RTCMultiConnectionServer.addSocket(socket)`, where `socket` is the individual client socket object provided by `socket.io`'s 'connection' event. -
Error: Cannot find module 'socket.io'
cause `socket.io` is a peer dependency that must be explicitly installed alongside `rtcmulticonnection-server`.fixInstall `socket.io` as a dependency: `npm install socket.io`. -
The server encountered a problem processing your request. Try again later. (HTTP 500)
cause This generic error might indicate that the `rtcmulticonnection-server` module was used in a pre-1.3.1 manner, expecting it to self-instantiate an HTTP server, which it no longer does.fixRefactor your application to explicitly create an HTTP server and a `socket.io` server, then integrate `rtcmulticonnection-server` by passing the client `socket` object to `RTCMultiConnectionServer.addSocket(socket)`.
Warnings
- breaking Starting from version 1.3.1, `rtcmulticonnection-server` no longer creates its own HTTP or Socket.io servers. Developers must provide an existing `socket.io` connection object to the `addSocket` method.
- gotcha The package's core functionality relies heavily on `socket.io`. Ensure `socket.io` is correctly installed, configured, and running in your application, including proper CORS settings for client connections.
- gotcha The last commit to the GitHub repository (master branch) was over 3 years ago (as of April 2026), indicating that the project is in maintenance mode and not actively developed. There might be a lack of updates for new WebRTC standards or `socket.io` versions.
Install
-
npm install rtcmulticonnection-server -
yarn add rtcmulticonnection-server -
pnpm add rtcmulticonnection-server
Imports
- RTCMultiConnectionServer
import RTCMultiConnectionServer from 'rtcmulticonnection-server';
const RTCMultiConnectionServer = require('rtcmulticonnection-server'); - addSocket
const addSocket = require('rtcmulticonnection-server').addSocket;RTCMultiConnectionServer.addSocket(socket);
Quickstart
const http = require('http');
const { Server } = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');
const app = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('RTCMultiConnection Server running. Connect via Socket.io.\n');
});
const io = new Server(app, {
cors: {
origin: "*", // Adjust for production security
methods: ["GET", "POST"]
}
});
io.on('connection', (socket) => {
console.log('Client connected:', socket.id);
RTCMultiConnectionServer.addSocket(socket);
socket.on('disconnect', () => {
console.log('Client disconnected:', socket.id);
});
});
const PORT = process.env.PORT || 9001;
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});