Smart Site
Home Docs Getting Started Troubleshooting

Troubleshooting

This guide summarizes the diagnosis and solutions for common issues with Smart SCADA Data Platform (ss-data), categorized by symptom for quick identification.

1. Backend Fails to Start

1.1 Port Conflict

Symptom: Startup error EADDRINUSE: address already in use :::4000

Diagnosis:

# Check the process occupying port 4000
netstat -ano | findstr ":4000"

Solution:

Option Action
Release the port taskkill /PID <process-id> /F
Change the port Modify PORT=4001 in .env.dev, sync frontend VITE_API_BASE_URL

1.2 Missing Dependencies or Compilation Failure

Symptom: pnpm dev reports module not found, or Cannot find module '@ss-node/ss-core'

Diagnosis:

  • Workspace package not compiled, dependents cannot find dist/ artifacts

Solution:

cd ss-services\ss-node
pnpm install          # Ensure dependencies are installed
pnpm build            # Compile all workspace packages

# Or compile a single package
pnpm --filter @ss-node/ss-core build
pnpm --filter @ss-node/ss-device build

⚠️ After modifying workspace package source code, you must recompile that package for it to take effect in dependents. See section 7 for details.

1.3 Database Locked

Symptom: SQLITE_BUSY: database is locked

Diagnosis:

  • Multiple processes accessing the same SQLite file simultaneously
  • Previous process did not exit normally, file lock not released

Solution:

  1. Ensure only one backend process accesses that DB file
  2. Close residual processes:
# Find node processes
tasklist | findstr node
taskkill /PID <process-id> /F
  1. If still locked, delete the -wal and -shm files and restart:
del ss-services\ss-node\data\ss-node.db-wal
del ss-services\ss-node\data\ss-node.db-shm

1.4 better-sqlite3 Compilation Failure

Symptom: better-sqlite3 reports compilation errors during pnpm install

Solution:

Platform Action
Windows npm install --global windows-build-tools or install Visual Studio Build Tools
Linux apt install python3 make g++
macOS xcode-select --install

2. Frontend Fails to Load

2.1 API Proxy Failure

Symptom: Browser F12 Network shows API requests returning 404 or connection refused

Diagnosis:

  1. Confirm backend is running: visit http://localhost:4000/api/v1/system/health
  2. Check that VITE_API_BASE_URL in frontend .env.development matches the backend port

Solution:

  • When backend port changes to 4001, sync the frontend:
VITE_API_BASE_URL=http://localhost:4001
VITE_WS_URL=http://localhost:4001
  • After modifying env, you must restart the frontend dev server

2.2 CORS Error

Symptom: Browser console reports Access-Control-Allow-Origin error

Diagnosis: Backend CORS configuration does not include the frontend domain

Solution:

Configure allowed origins in the backend env (comma-separated):

CORS_ORIGINS=http://localhost:5173,http://localhost:3000

By default, http://localhost:5173 and http://localhost:3000 are allowed. Production deployment needs to add the actual domain. CORS configuration is in main.ts.

2.3 Blank Page

Symptom: Visiting http://localhost:5173 shows a blank page

Diagnosis Steps:

  1. Check the F12 console for JS errors
  2. Verify the frontend started successfully (no errors in terminal)
  3. Clear browser cache and LocalStorage, then retry

3. Device Offline Troubleshooting

3.1 Device Status is Offline

Diagnosis Flow:

Device offline
   ├─ 1. Check if device enabled is on (database devices.enabled)
   ├─ 2. Check if collector is running (collector-bootstrap logs)
   ├─ 3. Check network connectivity (ping / telnet)
   ├─ 4. Check protocol configuration (host/port/unitId)
   └─ 5. Check collection logs data/logs/combined.log

Common Diagnostic Commands:

# Modbus TCP connectivity test
telnet 192.168.1.10 502

# View collection-related logs
findstr "collector" ss-services\ss-node\data\logs\combined.log

3.2 Virtual Device Offline

Symptom: Virtual device (protocol=virtual) also shows offline

Cause: Collector not started or device collection not enabled

Solution:

  1. Confirm device enabled=true
  2. Restart the backend service and check the startup logs to see if DeviceCollectorBootstrap loaded the device
  3. Check the PLUGIN_CONFIG_DIR directory permissions

3.3 Data Not Updating

Symptom: Device is online but tag values are not changing

Troubleshooting:

  • Check if the tag Collection Enabled is checked
  • Check if scanRate is too large
  • Check if the real-time data cache directory REALTIME_DATA_DIR has writes
  • When InfluxDB is configured but not connected, writes will fail but real-time push is unaffected

4. WebSocket Connection Issues

4.1 Connection Failure

Symptom: Frontend ws-monitor page shows disconnected, real-time data not refreshing

Diagnosis:

  1. Confirm VITE_WS_URL matches the backend port
  2. Browser F12 → Network → WS tab to view connection status
  3. Check backend logs for Socket.IO handshake records

Solution:

  • Port mismatch: modify frontend VITE_WS_URL
  • Reverse proxy: ensure Nginx forwards WebSocket (proxy_set_header Upgrade $http_upgrade)

4.2 Frequent Disconnects and Reconnects

Causes:

  • Heartbeat timeout (default configuration)
  • Unstable network
  • Backend restart

Solution:

  • Stabilize the network environment
  • Configure Redis to persist offline messages, avoiding loss of unread data after reconnection

4.3 No Data Push on Subscription

Troubleshooting:

  • Confirm the subscribe:data event carries the correct projectId
  • Confirm the device is online and collecting data
  • Check backend logs to see if data:update events are being emitted

5. Knowledge Base Directory Not Displayed

5.1 Knowledge Base is Empty

Symptom: Visiting the knowledge base page shows no content

Diagnosis:

  1. Confirm the KB_ROOT directory exists and has content:
dir ss-run\ss\data\faq\zh-CN
  1. Confirm KB_SUPPORTED_LANGS includes the target language
  2. Confirm the document frontmatter lang matches the directory name

Solution:

  • If the directory does not exist, create it and add documents
  • After modifying env, restart the backend service

5.2 Documents Not Refreshing

Symptom: Modifying Markdown does not update the page

Cause: I18N_WATCH=false or file watching not effective

Solution:

  • Set I18N_WATCH=true in the development environment
  • Restart the backend service to force reload

5.3 Frontmatter Format Error

Symptom: A single document does not display or parsing errors occur

Checks:

  • YAML format is correct (2-space indentation)
  • id is unique and includes the module path
  • lang matches the directory name
  • status is published

6. Database Migration Issues

6.1 Missing Table Structure After Upgrade

Symptom: After upgrading the version, reports no such table or no such column

Cause: Old database did not execute the new version migration scripts

Solution:

  1. Check the INSERT OR IGNORE and ALTER TABLE statements in the new version's ../../../../../../../ss-services/ss-node/data/init/init-system-db.sql
  2. On startup, insertMissingMenus() automatically adds missing menus
  3. Manually execute the missing SQL statements

6.2 Project Database Not Initialized

Symptom: After creating a new project, the device table does not exist

Cause: PROJECT_DB_INIT_DIR path is incorrect or initialization scripts are missing

Solution:

  • Confirm PROJECT_DB_INIT_DIR points to the directory containing init-system-db.sql
  • Delete the project directory and recreate the project to trigger auto-initialization

6.3 Database File Corruption

Symptom: database disk image is malformed

Solution:

  1. Stop the backend service
  2. Back up the corrupted db file
  3. Restore the latest backup from BACKUP_DIR
  4. If no backup, delete the db file to reinitialize (⚠️ data loss)
# Recover using sqlite3 command line (if recoverable)
sqlite3 ss-node.db ".recover" > recovered.sql
sqlite3 new.db < recovered.sql

7. Workspace Package Build Issues

7.1 Source Code Changes Not Taking Effect

Symptom: Modified @ss-node/ss-core source code, but dependent behavior did not change

Cause: Workspace packages need recompilation; dependents reference the dist/ artifacts

Solution:

cd ss-services\ss-node

# Compile a single package
pnpm --filter @ss-node/ss-core build

# Compile all packages (in dependency order)
pnpm build

# Restart backend
pnpm dev

7.2 Package Dependency Order Error

Symptom: Compilation reports that a dependency package's dist/ does not exist

Solution:

Compile in dependency order: ss-sdk → ss-core → ss-device / ss-project / other business packages.

Running pnpm build directly handles the dependency order automatically (pnpm -r build executes in topological order).

7.3 Frontend Workspace Package Not Taking Effect

The same applies to the frontend. After modifying packages like @scada-editor/core, compile them:

cd ss-editor
pnpm --filter @scada-editor/core build

8. Log Location Quick Reference

Log Type Location Description
Backend combined log {DATA_DIR}/logs/combined.log All levels
Backend error log {DATA_DIR}/logs/error.log ERROR only
Frontend console Browser F12 Console Runtime errors
Startup log Terminal stdout Startup process

9. General Diagnostic Steps

When encountering unknown issues, follow this order for troubleshooting:

  1. Check logs: Does data/logs/error.log have ERROR entries
  2. Check health: Does http://localhost:4000/api/v1/system/health return ok
  3. Verify configuration: Are env file paths, ports, and tokens correct
  4. Recompile: Are workspace packages up to date (pnpm build)
  5. Restart service: Clear in-memory state
  6. Check docs: System Overview and the corresponding module documentation