A Cordova plugin that enables running a single, lightweight WebSocket server on Android and iOS devices. Version 1.6.0 is the latest release. It allows starting/stopping a server on a specified port, managing WebSocket connections (open, message, close events), and sending/receiving text and binary messages. The server is not a background service and stops when the Cordova view is destroyed. Key differentiators: simple callback-based API, built-in support for network interface enumeration, and origin/protocol validation. The plugin relies on platform-specific libraries: TooTallNate Java-WebSocket for Android and PocketSocket for iOS.
npm install cordova-plugin-websocket-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates starting a WebSocket server on port 8080 after device ready, with event handlers for connection lifecycle.
Do not rely on the server persisting after app is backgrounded or terminated.
Use wsserver.send({uuid: '...'}, msg) instead of wsserver.send('...', msg).Pass a specific port number (e.g., 8080) instead of 0.
Always provide at least a failure callback to catch errors.
Wrap code in 'deviceready' event listener or run on a real device/emulator.
Ensure cordova.plugins.wsserver is available after deviceready. Check plugin installation.
Choose an unused port (e.g., >1024) and verify network permissions in config.xml.