Engine.IO is a foundational real-time communication library that underpins Socket.IO, providing the bidirectional connection layer between client and server. It offers robust transport mechanisms to ensure maximum reliability across various network conditions, including proxies, load balancers, and personal firewall software. Currently stable at version 6.6.6, Engine.IO receives updates in alignment with the broader Socket.IO ecosystem, often focusing on bug fixes, dependency updates, and security patches, as seen in recent releases. Its design prioritizes minimal client size and scalability, making it suitable for high-performance applications. Unlike higher-level abstractions, Engine.IO exposes a 100% Node.js core-style API, emphasizing a direct and unopinionated approach to real-time communication without extensive API sugar, allowing developers granular control over the connection lifecycle and underlying transports.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Since Engine.IO v6, the library offers both CommonJS and ES Modules exports. Prefer named imports for clarity and tree-shaking when using ESM. The `require('engine.io')` pattern is for CommonJS.
import { Server } from 'engine.io';
The `listen` function provides a convenient way to quickly set up an Engine.IO server on a given port, abstracting HTTP server creation. Use named import for ESM.
import { listen } from 'engine.io';
Represents an individual client connection. Instances of `Socket` are emitted by the `Server` and provide methods for sending/receiving data and managing connection state.
import { Socket } from 'engine.io';
This quickstart demonstrates how to set up an Engine.IO server, attach it to an existing Node.js HTTP server, and handle client connections, messages, and disconnections. It includes basic error handling and illustrates both sending and receiving data.
import { Server } from 'engine.io';
import * as http from 'http';
// Create a basic HTTP server
const httpServer = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Engine.IO is running!\n');
});
// Attach Engine.IO to the HTTP server
const eioServer = new Server({
pingInterval: 1000, // Client pings server every 1 second
pingTimeout: 500 // Server considers client disconnected if no ping for 0.5 seconds
});
eioServer.attach(httpServer);
// Handle connections
eioServer.on('connection', (socket) => {
console.log(`Client connected: ${socket.id}`);
// Send a message to the client
socket.send('Hello from Engine.IO server!');
// Listen for messages from the client
socket.on('message', (data) => {
console.log(`Received message from ${socket.id}: ${data}`);
// Echo the message back to the client
socket.send(`Server received: ${data}`);
});
// Handle client disconnection
socket.on('close', (reason, description) => {
console.log(`Client ${socket.id} disconnected. Reason: ${reason}, Description: ${description}`);
});
// Handle errors
socket.on('error', (err) => {
console.error(`Error on socket ${socket.id}:`, err);
});
});
// Start the HTTP server
const PORT = process.env.PORT || 3000;
httpServer.listen(PORT, () => {
console.log(`Engine.IO server listening on http://localhost:${PORT}`);
console.log('Connect with an Engine.IO client, e.g., in browser: new eio.Socket(\'ws://localhost:3000\');');
});
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.