{"id":49513,"library":"think-websocket-socket.io","title":"ThinkJS Socket.io WebSocket Adapter","description":"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.","status":"maintenance","version":"1.0.13","language":"javascript","source_language":"en","source_url":"https://github.com/thinkjs/think-websocket-socket.io","tags":["javascript","typescript"],"install":[{"cmd":"npm install think-websocket-socket.io","lang":"bash","label":"npm"},{"cmd":"yarn add think-websocket-socket.io","lang":"bash","label":"yarn"},{"cmd":"pnpm add think-websocket-socket.io","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for socket.io server functionality","package":"socket.io","optional":false},{"reason":"ThinkJS framework as peer dependency","package":"thinkjs","optional":false}],"imports":[{"note":"Package is CommonJS; no default export. Use require() or import as namespace.","wrong":"import socketio from 'think-websocket-socket.io';","symbol":"default (module)","correct":"const socketio = require('think-websocket-socket.io');"},{"note":"Must require the module and assign to handle property in config.","wrong":"exports.websocket = { type: 'socketio', handle: 'think-websocket-socket.io' }","symbol":"websocket config","correct":"const socketio = require('think-websocket-socket.io'); exports.websocket = { type: 'socketio', socketio: { handle: socketio } }"},{"note":"Types are bundled; use namespace import for TS. No default export.","wrong":"import socketio from 'think-websocket-socket.io';","symbol":"TypeScript types","correct":"import * as socketio from 'think-websocket-socket.io';"}],"quickstart":{"code":"// 1. Install\n// npm install think-websocket-socket.io socket.io\n\n// 2. src/config/adapter.js\nconst socketio = require('think-websocket-socket.io');\nmodule.exports.websocket = {\n  type: 'socketio',\n  socketio: {\n    handle: socketio,\n    allowOrigin: null,\n    path: '/socket.io',\n    adapter: null,\n    messages: [{\n      open: '/websocket/open',\n      close: '/websocket/close',\n      addUser: '/websocket/addUser'\n    }]\n  }\n};\n\n// 3. src/config/config.js\nmodule.exports = {\n  stickyCluster: true\n};","lang":"javascript","description":"Configure ThinkJS to use socket.io for WebSocket with custom messages and sticky cluster."},"warnings":[{"fix":"Consider using socket.io directly with ThinkJS or migrate to a newer framework.","message":"Package is in maintenance mode; no updates for several years. Unlikely to receive security patches.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Add 'stickyCluster: true' to src/config/config.js.","message":"Must set stickyCluster: true in config.js for multi-process deployments; otherwise WebSocket connections will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'const socketio = require('think-websocket-socket.io');' and set '{ handle: socketio }'.","message":"Config object requires 'handle' property with the required module; using a string will not work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use require() or import * as ns syntax.","message":"Package is CommonJS; cannot be imported with ESM default import in Node <13.2 or without 'type': 'module'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass adapter instance as shown in docs; cannot change after server start.","message":"Adapter option (e.g., socket.io-redis) must be set at config time, not at runtime.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2020':14 'action':39 'adapt':4,6,27 'alloworigin':26 'altern':47 'applic':23 'broadcast':38 'configur':24 'consid':46 'design':40 'e.g':28 'emit':36 'framework':10 'integr':18 'javascript':51 'last':12 'low':44 'mainten':45 'multi':33 'multi-nod':32 'new':49 'node':34 'path':25 'project':50 'redi':30 'socket.io':2,5,19,29 'support':35 'thinkj':1,9,22,42 'typescript':52 'updat':13 'use':15 'v1.0.x':11 'v2.x/v3.x':43 'websocket':3,20","created_at":"2026-06-07T17:02:08.863783+00:00","updated_at":"2026-06-07T17:02:08.863783+00:00","problems":[{"fix":"Use 'handle: socketio' in config, not 'socketio()'.","cause":"Trying to use the required module as a function; it's an object.","error":"TypeError: socketio is not a function"},{"fix":"Set stickyCluster: true in config.js or use environment variable PORT.","cause":"Multiple instances on same port without sticky cluster.","error":"Error: listen EADDRINUSE :::3000"},{"fix":"Run 'npm install think-websocket-socket.io' (ensure socket.io is also installed).","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'think-websocket-socket.io'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/thinkjs/think-websocket-socket.io#readme","github":"https://github.com/thinkjs/think-websocket-socket.io","docs":null,"changelog":null,"pypi":null,"npm":"think-websocket-socket.io","openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}