Skip to main content

Run a server

The IOSignal server relays channel publish/subscribe traffic and direct CID messages between clients. Browsers and Node.js connect over WebSocket (port); Arduino and IOCongSocket connect over TCP (congPort). Use Node.js code to embed the server in an app, or the CLI to run one without code. Requires Node.js 22.16 or later.

mkdir iosignal-server
cd iosignal-server
npm init -y
npm install iosignal

Save as server.mjs:

import { Server, version } from 'iosignal';

const server = new Server({ port: 7777 });
server.on('ready', () => console.log(`iosignal ${version}: ws://localhost:7777`));

Run node server.mjs. To support Arduino and other CongSocket clients as well, set both ports: new Server({ port: 7777, congPort: 8888 }). Use httpServer and wsPath when integrating with an existing HTTP server. The server API covers the remaining options.

Verify delivery​

Run the quickstart receiver and sender in separate terminals.

Before production​

  • To accept other devices, match addresses, ports, and firewall rules in server addresses and connection environments.
  • HTTPS browser apps require a TLS-enabled wss:// endpoint. Ensure the client address and port match your server.
  • Review server authentication before exposing the server. A successful local test does not verify public deployment, TLS, or authentication.

For protocol differences, see WebSocket, MQTT, and Socket.IO.