Communication Server Technicals
Overview
DroneEngage Communication Server is the real-time messaging backbone for the DroneEngage/Andruav drone management ecosystem. It handles WebSocket-based communication between drone units and Ground Control Stations (GCS), implements server-to-server mesh relay for scalable message propagation, and supports message routing with group and individual targeting using Ed25519 cryptographic authentication.
Tech Stack
Runtime: Node.js >= 18
Web Framework: Express.js
Database: MySQL2
Real-time: WebSocket (ws library)
Authentication: Ed25519 S2S authentication
UDP: udp-packet for UDP proxy functionality
Utilities: lodash, moment, uuid, randomstring, jspack
Architecture
Three operational modes:
1. Standalone Mode
Independent server for local communication
No S2S relay required
Suitable for small-scale operations
2. Child Server Mode
Connects to parent server for message relay
Receives messages from parent
Forwards local messages to parent
Part of distributed mesh network
3. Parent (Super) Server Mode
Accepts child connections
Forwards messages between children
Implements mesh relay for scalability
Central hub in distributed deployment
Core Components
WebSocket Server
Main communication channel for units and GCS
Handles client connections with temporary key validation
Manages account rooms for message routing
Maintains active sender lists
S2S Relay
Server-to-server mesh network for message propagation
Ed25519 cryptographic authentication
Loop prevention using path tracking
Message routing between parent and child servers
UDP Proxy
Handles UDP packet forwarding
Kernel buffer size checking and adjustment
Fixed port configuration option
Used for MAVLink and other UDP protocols
Chat System
Message routing and room management
Group and individual targeting
Active sender tracking
Connection lifecycle management
Key Files
Core Server Files
server.js- Main entry point, initializes all serversserver.config- JSON configuration (supports –config override)package.json- Dependencies and scriptsjs_constants.js- Message types, routing constants
Communication Server Components
server/js_andruav_comm_server.js- Main WebSocket serverserver/js_s2s_auth.js- Ed25519 S2S authenticationserver/js_udp_proxy.js- UDP packet proxyserver/js_andruavTasks_v2.js- Task management
Chat System
server/chat_server/js_andruav_chat_server.js- Chat system singletonserver/chat_server/js_chat_routing.js- Message routing logicserver/chat_server/js_chat_connection.js- Connection managementserver/chat_server/js_chat_relay.js- S2S message relay
S2S Components
server/server_to_server/js_parent_comm_server.js- Parent server S2Sserver/server_to_server/js_child_comm_server.js- Child server S2S
Helpers
helpers/hlp_args.js- Argument parsing utilitieshelpers/hlp_strings.js- String manipulation utilitieshelpers/hlp_validation.js- Input validationhelpers/hlp_colors.js- Console color formatting
Configuration
Configuration is centralized in server.config (JSON format). Key sections:
Server Identity
server_id- Unique server identifierserver_ip- Listening IP (default:::)server_port- Listening port (default: 9966)public_host- Public host/IP as seen by clientsserver_sid- Unique server ID for multi-server deployments
Database Connection
MySQL credentials
Connection pool configuration
Database name and host
S2S Authentication
Ed25519 private key
Trusted public keys
Authentication server connection details
SSL/TLS
SSL certificate paths
SSL private key path
CA certificate path
SSL enable/disable flags
Server Roles
enable_super_server- Enable parent server modeenable_persistant_relay- Enable persistent relayParent/child server connection details
Logging
Log level configuration
Log file paths
Log rotation settings
Memory Management
memory_max- Memory limit in MBAuto-restart on limit exceeded
Coding Standards
Logging
Use
global.m_loggerfor logging (if enabled)Check
global.m_loggerexistence before useConsistent log format across modules
Singleton Pattern
Use singleton pattern for chat server:
global.m_chat_server_singelton_get_instance()Ensure thread-safe initialization
Document singleton usage
Global Objects
Several modules attached to
globalfor easy accessBe aware of global state
Document global dependencies
Memory Management
Memory monitoring with auto-restart on limit exceeded
Prevent memory leaks from causing crashes
Monitor memory usage every 60 seconds
Error Handling
Check
global.m_loggerexistence before useImplement comprehensive error handling
Provide meaningful error messages
Utilities
Reuse utilities in
helpers/directoryAvoid code duplication
Follow existing patterns
Message Routing
Messages routed based on ty (type) and tg (target) fields:
Message Types
‘g’ (group broadcast) - Send to all members of a group
‘i’ (individual) - Send to specific unit ID
‘s’ (system/local) - System-level messages
Message Targets
'_GCS_'- All Ground Control Stations'_GD_'- All drone units'_AGN_'- All agentsSpecific unit ID - Individual targeting
Loop Prevention
Uses
_patharray to track message traversalPrevents infinite message loops
Each server adds its ID to path
Message Forwarding
Local Messages: Forwarded to relay servers
External Messages: Delivered locally only (no re-forwarding)
S2S Authentication
Ed25519 Cryptographic Signatures
Child servers connect to parent with private key
Parent servers verify child signatures with trusted public keys
Challenge-response authentication flow
Keys generated via authenticator’s
scripts/gen_s2s_keys.sh
Authentication Flow
Child server initiates WebSocket connection
Parent server sends Ed25519 challenge
Child server signs challenge with private key
Parent server verifies signature with trusted public key
Connection established if signature valid
Persistent connection maintained
Database
MySQL database for persistent storage:
Tables
User accounts
Communication server registration
Message history (if configured)
Task persistence
Operations
Connection pooling
Prepared statements
Error handling
Transaction support
Development
Setup
npm install
cp server.config server.config.local
# Edit server.config.local
mkdir -p server/ssl
openssl req -x509 -newkey rsa:4096 -keyout server/ssl/domain.key -out server/ssl/domain.crt -days 365 -nodes
npm start
Testing
npm test
npm run test:watch
node --test test/unit/relay.test.js
Deployment
Parent Server
./deployment/run_parent.sh
Child Server
./deployment/run_slave.sh
Security Features
SSL/TLS for WebSocket connections
Ed25519 cryptographic S2S authentication
Configurable trusted server keys
Memory limit monitoring with auto-restart
UDP proxy with kernel buffer management
Temporary login key validation
Account room isolation
UDP Proxy
Functionality
Handles UDP packet forwarding between units
Kernel buffer size checking and adjustment
Fixed port configuration option
Used for MAVLink and other UDP protocols
Configuration
Port configuration
Buffer size limits
Kernel parameter tuning
Memory Management
Monitoring
Configurable memory limit (memory_max in MB)
Automatic server restart when limit exceeded
Memory monitoring every 60 seconds
Prevents memory leaks from causing crashes
Implementation
Memory usage tracking
Graceful shutdown on restart
State preservation where possible
Documentation
README.md- User-facing documentationwiki/MessagePropagation.md- Message routing and relay architecturewiki/S2SAuthentication.md- Server-to-server authentication setup
Version
3.9.11