Registry / communication / think-websocket-socket.io

think-websocket-socket.io

JSON →
library1.0.13jsnpmunverified

Socket.io adapter for the ThinkJS framework (v1.0.x, last updated 2020). Use it to integrate Socket.io WebSocket into ThinkJS applications. Configurable path, allowOrigin, adapter (e.g., socket.io-redis for multi-node). Supports emit and broadcast actions. Designed for ThinkJS v2.x/v3.x. Low maintenance; consider alternatives for new projects.

npm install think-websocket-socket.io
INSTALL
IMPORT
SIG · THINK-WEBSOCKET-SO
T
think-websocket-socket.io
communicationjavascriptv1.0.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (module)
✓ const socketio = require('think-websocket-socket.io');
✗ import socketio from 'think-websocket-socket.io';
Package is CommonJS; no default export. Use require() or import as namespace.
websocket config
✓ const socketio = require('think-websocket-socket.io'); exports.websocket = { type: 'socketio', socketio: { handle: socketio } }
✗ exports.websocket = { type: 'socketio', handle: 'think-websocket-socket.io' }
Must require the module and assign to handle property in config.
TypeScript types
✓ import * as socketio from 'think-websocket-socket.io';
✗ import socketio from 'think-websocket-socket.io';
Types are bundled; use namespace import for TS. No default export.

Configure ThinkJS to use socket.io for WebSocket with custom messages and sticky cluster.

// 1. Install // npm install think-websocket-socket.io socket.io // 2. src/config/adapter.js const socketio = require('think-websocket-socket.io'); module.exports.websocket = { type: 'socketio', socketio: { handle: socketio, allowOrigin: null, path: '/socket.io', adapter: null, messages: [{ open: '/websocket/open', close: '/websocket/close', addUser: '/websocket/addUser' }] } }; // 3. src/config/config.js module.exports = { stickyCluster: true };
Debug
Known issues
deprecatedPackage is in maintenance mode; no updates for several years. Unlikely to receive security patches.
fix
Consider using socket.io directly with ThinkJS or migrate to a newer framework.
affects: >=1.0.0
gotchaMust set stickyCluster: true in config.js for multi-process deployments; otherwise WebSocket connections will fail.
fix
Add 'stickyCluster: true' to src/config/config.js.
affects: >=1.0.0
gotchaConfig object requires 'handle' property with the required module; using a string will not work.
fix
Use 'const socketio = require('think-websocket-socket.io');' and set '{ handle: socketio }'.
affects: >=1.0.0
gotchaPackage is CommonJS; cannot be imported with ESM default import in Node <13.2 or without 'type': 'module'.
fix
Use require() or import * as ns syntax.
affects: >=1.0.0
gotchaAdapter option (e.g., socket.io-redis) must be set at config time, not at runtime.
fix
Pass adapter instance as shown in docs; cannot change after server start.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: socketio is not a function
Trying to use the required module as a function; it's an object.
fix
Use 'handle: socketio' in config, not 'socketio()'.
Error: listen EADDRINUSE :::3000
Multiple instances on same port without sticky cluster.
fix
Set stickyCluster: true in config.js or use environment variable PORT.
Cannot find module 'think-websocket-socket.io'
Package not installed or not in node_modules.
fix
Run 'npm install think-websocket-socket.io' (ensure socket.io is also installed).
Upgrade
Version history
1.0.13latest on npm
Audit
Dependencies
socket.iorequiredpeer dependency for socket.io server functionality
thinkjsrequiredThinkJS framework as peer dependency
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
think-websocket-socket.io — npm install think-websocket-socket.io · libregistry