Registry / http-networking / engine.io

engine.io

JSON →
library6.6.6jsnpmunverified

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.

http-networkingweb-frameworkcommunication
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
musl
node 18226 runs
build_error
glibc
node 18226 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\');'); });
Debug
Known footguns
breakingA critical security vulnerability (CVE-2026-33151) affecting `socket.io-parser` has been patched across several `socket.io-parser` versions (>=3.3.5, >=3.4.4, >=4.2.6). While `engine.io` itself does not directly depend on `socket.io-parser`, this module is a fundamental component of the broader Socket.IO ecosystem, including setups where `engine.io` is used as a foundation for `socket.io`. The vulnerability addresses a limit on binary attachments to prevent potential denial-of-service or memory exhaustion attacks. Users running `socket.io` should ensure their `socket.io-parser` dependency is updated to mitigate this risk.
gotchaNode.js's `url.parse()` function has been deprecated in favor of the `new URL()` constructor. While `engine.io`'s internal handling should be updated, applications leveraging `engine.io` that manually parse URLs using `url.parse()` should migrate to `new URL()` to avoid deprecation warnings and ensure future compatibility, especially with newer Node.js versions.
gotchaThe `engine.io` library ships with both CommonJS (CJS) and ES Module (ESM) exports. The provided README examples predominantly use CJS `require()`. When integrating into an ES Module project, direct named `import { Server } from 'engine.io';` should be used. Mixing `require()` with `import` statements or incorrect import paths in ESM projects can lead to 'ERR_REQUIRE_ESM' or 'default is not a constructor' errors.
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.

Agent activity
14 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
bytedance
1
Resources