Registry / devops / architect-websocket-server

architect-websocket-server

JSON →
library1.2.0jsnpmunverified

WebSocket server plugin for the Architect framework, supporting multiplexed channels (e.g., printer, chatroom) and route mounting via SockJS. Version 1.2.0 is the latest stable release; the package appears to be in maintenance mode with no recent updates. It integrates tightly with Architect's plugin system and exposes an `imports.wsserver` object for route registration. Unlike standalone WebSocket libraries, this is specifically designed as an Architect plugin and requires the Architect runtime.

npm install architect-websocket-server
INSTALL
IMPORT
SIG · ARCHITECT-WEBSOCKE
A
architect-websocket-server
devopsjavascriptv1.2.0
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.

wsserver
// Access via imports object in an Architect plugin: module.exports = function setup(options, imports, register) { var wsserver = imports.wsserver; // ... };
import { wsserver } from 'architect-websocket-server';
This package does not export the wsserver object directly. It is injected into the plugin's imports by Architect at runtime. Do not attempt to import it as a module.
router
var router = wsserver.routers.printer;
var router = wsserver.router;
Routers are accessed via the specific channel name (e.g., 'printer', 'chatroom'), not a generic 'router' property.
WebSocket server
// The server is started automatically when Architect initializes the plugin.
new WebSocket.Server({ port: 8080 });
You do not create a WebSocket server manually. Configuration is provided via the Architect config file (port, host, etc.).

Demonstrates how to set up the Architect WebSocket Server plugin with channels, mount a route, and start the application.

// config.js module.exports = [{ packagePath: "architect-websocket-server", port: 8080, host: '0.0.0.0', channels: ['printer', 'chatroom'] }, './routes']; // routes/index.js module.exports = function setup(options, imports, register) { var wsserver = imports.wsserver; var router = wsserver.routers.printer; router.mount('catalogue', function (req, ws) { ws.send({message: 'hello, world'}); }); register(); }; module.exports.consumes = ['wsserver']; // app.js var path = require('path'); var architect = require("architect"); var configPath = path.join(__dirname, "config.js"); var config = architect.loadConfig(configPath); architect.createApp(config, function (err, app) { if (err) throw err; console.log("app ready"); });
Debug
Known issues
gotchaThe package is tightly coupled to the Architect plugin system. It cannot be used standalone without Architect.
fix
Ensure your application uses Architect and the plugin is listed in the config array.
affects: *
gotchaThe `channels` config option defines which multiplexed channels are available. Accessing a channel not in the list (e.g., wsserver.routers.unknown) will result in undefined.
fix
List all required channels in the config object, and check that the channel name matches exactly (case-sensitive).
affects: *
deprecatedThis package uses SockJS which is in maintenance mode. Modern applications should use native WebSocket or libraries like ws.
fix
Consider using the 'ws' library directly with Architect's plugin system, if needed.
affects: *
gotchaThe `router.mount` callback receives a raw SockJS connection object, not a standard WebSocket. Methods like `send` may behave differently.
fix
Use SockJS API (e.g., conn.write) instead of standard WebSocket methods.
affects: *
gotchaThe `prefix` config option must match the path under which SockJS is served (default '/sockjs'). If unspecified, the endpoint is '/sockjs'.
fix
Set prefix if you need a custom path, otherwise ensure client connects to '/sockjs'.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read property 'printer' of undefined
Accessing wsserver.routers.printer before the plugin is fully initialized or the channel is not configured.
fix
Make sure the 'printer' channel is listed in the channels array in config.js, and access the router only inside the setup callback.
ReferenceError: wsserver is not defined
Attempting to use wsserver outside of the plugin setup function or without declaring it via imports.
fix
Use the imports parameter in the setup function: module.exports = function(options, imports, register) { var wsserver = imports.wsserver; }
Error: listen EADDRINUSE
Port specified in config is already in use by another process.
fix
Change the port in config or kill the process occupying the port.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
architectrequiredRequired runtime framework; this package is an Architect plugin and cannot function without Architect's bootstrap.
sockjsrequiredWebSocket polyfill/fallback used as the underlying transport.
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
2
Resources
architect-websocket-server — npm install architect-websocket-server · libregistry