Skip to main content

Troubleshooting Event Monitoring

This guide provides solutions to common problems encountered when monitoring OPC UA events.

No Events Received

Symptom

The Monitor Event node is running but no messages are output, even though events should be occurring.

Possible Causes & Solutions

1. Server Doesn't Support Event Monitoring

Check:

  • Verify the OPC UA server has event monitoring capabilities
  • Review server documentation for event support
  • Test with another OPC UA client (UaExpert, etc.)

Solution:

// Test with a known event-generating server
// Try the official OPC UA demo server
endpoint: "opc.tcp://opcuademo.sterfive.com:26543"
nodeId: "i=2253" // Server object

2. Wrong NodeId (Object Doesn't Generate Events)

Check:

  • Verify the NodeId points to an object (not a variable)
  • Confirm the object generates events

Solution:

// Start with the Server object - always generates events
nodeId: "i=2253"

// Then try specific equipment
nodeId: "ns=2;s=Equipment.Reactor1"

Test using Read Node:

// Read the EventNotifier attribute
attributeId: "EventNotifier"
// Non-zero value means object generates events

3. Where Clause Too Restrictive

Check:

  • Remove Where Clause temporarily to see all events
  • Verify event type names are correct

Solution:

// Step 1: Remove filter
whereClause: ""

// Step 2: Examine received events
// Debug output will show EventType values

// Step 3: Add correct filter
whereClause: "ofType('AlarmConditionType')" // Verify type name

4. Subscription Not Active

Check:

  • Verify subscription is configured in endpoint
  • Check endpoint connection status (should be green)
  • Review subscription parameters

Solution:

// Verify endpoint configuration:
// 1. Open endpoint configuration
// 2. Check "Subscriptions" section
// 3. Ensure at least one subscription exists
// 4. Verify publishing interval is reasonable (1000ms)

5. Events Not Occurring

Check:

  • Events may simply not be happening on the server
  • Check if this is expected behavior

Solution:

// Generate test events if possible
// Some servers have methods to generate test events

// Or monitor the Server object which has system events
nodeId: "i=2253"
whereClause: "ofType('SystemEventType')"

Diagnostic Steps

Step 1: Verify Basic Connectivity

// Use a Read node to verify connection
nodeId: "i=2253"
attributeId: "BrowseName"
// Should return "Server"

Step 2: Check Event Notifier

// Read EventNotifier attribute
nodeId: "i=2253"
attributeId: "EventNotifier"
// Value > 0 means events are supported

Step 3: Remove All Filters

// Simplest possible configuration
nodeId: "i=2253"
whereClause: ""
selectClause: "EventId,Time,Message"

Step 4: Check Debug Log

  • Open Node-RED debug panel
  • Deploy the flow
  • Look for error messages
  • Check connection status indicator

Too Many Events

Symptom

Receiving an overwhelming number of events, causing performance issues or making it hard to identify important events.

Possible Causes & Solutions

1. No Where Clause Filter

Problem: Receiving all events from all sources

Solution:

// Add type filter
whereClause: "ofType('AlarmConditionType')"

// Or severity filter
whereClause: "Severity >= 600"

// Or combination
whereClause: "ofType('AlarmConditionType') AND Severity >= 700"

2. Monitoring Wrong Object

Problem: Monitoring Server object or high-level folder receives events from many sources

Solution:

// Change from Server object
nodeId: "i=2253" // Too broad

// To specific equipment
nodeId: "ns=2;s=Equipment.Reactor1" // More specific

3. Low Severity Threshold

Problem: Including informational events that aren't needed

Solution:

// Raise severity threshold
whereClause: "Severity >= 700" // Only warnings and above

// Or only critical
whereClause: "Severity >= 800" // Only critical alarms

4. Event Storms

Problem: Multiple related events triggering rapidly

Solution - Rate Limiting:

// Function node: Rate limit events
const rateLimit = 1000; // Max 1 per second
const lastEvent = context.get('lastEvent') || 0;
const now = Date.now();

if (now - lastEvent < rateLimit) {
return null;
}

context.set('lastEvent', now);
return msg;

Solution - Aggregation:

// Function node: Aggregate events
const events = context.get('events') || [];
events.push(msg.payload);

const lastEmit = context.get('lastEmit') || 0;
const now = Date.now();

if (now - lastEmit > 5000) { // Emit every 5 seconds
msg.payload = {
count: events.length,
events: events.slice(0, 10) // First 10 events
};
context.set('events', []);
context.set('lastEmit', now);
return msg;
}

context.set('events', events);
return null;

Performance Optimization

Reduce Publishing Interval:

// In subscription configuration
publishingInterval: 5000 // 5 seconds instead of 1 second

Use Multiple Monitors:

// Separate high-priority from low-priority
// Node 1: Critical only
whereClause: "Severity >= 800"

// Node 2: Standard
whereClause: "Severity >= 500 AND Severity < 800"

Missing Event Fields

Symptom

Event messages don't contain expected fields, or field values are null/undefined.

Possible Causes & Solutions

1. Field Not Available for Event Type

Problem: Selected field doesn't exist for this event type

Check:

// Different event types have different fields
// BaseEventType: EventId, Time, Message, Severity
// AlarmConditionType: Also has ActiveState, AckedState
// AuditEventType: Also has ActionTimeStamp, ClientUserId

Solution:

// Use graphical selector to see available fields
// Click "..." button next to Select Clause

// Or start with basic fields
selectClause: "EventId,Time,Message,Severity"

// Add type-specific fields only if event type matches
selectClause: "EventId,Time,Message,Severity,ActiveState,AckedState"

2. Incorrect Field Name

Problem: Typo or wrong field name in Select Clause

Solution:

// ❌ Wrong
selectClause: "event_id,timestamp,msg"

// ✅ Correct
selectClause: "EventId,Time,Message"

// Use graphical selector to avoid typos

3. Optional Fields Not Populated

Problem: Server doesn't populate optional fields

Check:

// Some servers may not populate all optional fields
// Check event payload in debug

Solution:

// Function node: Handle missing fields
const event = msg.payload;

// Provide defaults for missing fields
msg.payload = {
eventId: event.EventId || 'unknown',
time: event.Time || new Date().toISOString(),
message: event.Message || 'No message',
severity: event.Severity || 0,
source: event.SourceName || 'Unknown source'
};

return msg;

Validation Function

// Function node: Validate required fields
const requiredFields = ['EventId', 'Time', 'Message', 'Severity'];
const event = msg.payload;
const missingFields = [];

requiredFields.forEach(field => {
if (event[field] === undefined || event[field] === null) {
missingFields.push(field);
}
});

if (missingFields.length > 0) {
node.warn(`Missing fields: ${missingFields.join(', ')}`);
// Optionally drop the event
return null;
}

return msg;

Events Delayed

Symptom

Events arrive later than expected, with noticeable delay from when they occur to when Node-RED receives them.

Possible Causes & Solutions

1. Subscription Publishing Interval Too Long

Problem: Subscription batches notifications infrequently

Check:

// Check subscription configuration
publishingInterval: 5000 // 5 seconds - may be too long

Solution:

// Reduce publishing interval
publishingInterval: 100 // 100ms for near real-time
publishingInterval: 500 // 500ms for fast response
publishingInterval: 1000 // 1 second for normal operation

2. Network Latency

Problem: Network delays between server and Node-RED

Check:

// Function node: Measure latency
const eventTime = new Date(msg.payload.Time);
const receiveTime = new Date();
const latency = receiveTime - eventTime;

node.log(`Event latency: ${latency}ms`);

if (latency > 5000) {
node.warn(`High latency detected: ${latency}ms`);
}

return msg;

Solution:

  • Check network connection quality
  • Reduce network hops
  • Use local server if possible
  • Check firewall/router settings

3. Server Processing Delay

Problem: Server is slow to generate or process events

Check:

  • Review server performance metrics
  • Check server logs for issues
  • Verify server isn't overloaded

Solution:

  • Optimize server configuration
  • Reduce number of monitored items
  • Upgrade server hardware
  • Contact server administrator

4. Node-RED Queue Buildup

Problem: Node-RED can't process events fast enough

Check:

// Monitor queue size
const queueSize = context.get('queueSize') || 0;
node.log(`Queue size: ${queueSize}`);

if (queueSize > 100) {
node.warn('Event processing backlog detected');
}

Solution:

// Optimize processing function
// Avoid heavy computation in event handler
// Move processing to separate flow

// Or batch process
const batch = context.get('batch') || [];
batch.push(msg.payload);

if (batch.length >= 10) {
msg.payload = batch;
context.set('batch', []);
return msg;
}

context.set('batch', batch);
return null;

Connection Issues

Symptom

Monitor Event node shows disconnected or errors occur intermittently.

Possible Causes & Solutions

1. Endpoint Configuration Issue

Check:

  • Verify endpoint URL is correct
  • Check authentication credentials
  • Review security settings

Solution:

// Test endpoint with simple Read node first
// Verify connection works before monitoring events

// Check endpoint configuration:
// - URL format: opc.tcp://server:port
// - Security mode and policy
// - Username/password if required

2. Subscription Timeout

Problem: Subscription expires due to inactivity

Check:

// Verify subscription lifetime settings
requestedLifetimeCount: 60 // Should be > 3x publishing interval

Solution:

// Increase lifetime
requestedLifetimeCount: 100

// Or reduce publishing interval
publishingInterval: 1000

3. Server Restart

Problem: Server restarted, subscription lost

Solution:

  • Monitor Event node should automatically reconnect
  • Check Node-RED logs for reconnection messages
  • Verify node status indicator

Manual Reconnect:

// Redeploy flow to force reconnection
// Or restart Node-RED

Where Clause Errors

Symptom

Error messages about invalid Where Clause, or no events received with complex filters.

Common Issues & Solutions

1. Syntax Errors

Problem: Incorrect Where Clause syntax

Examples:

// ❌ Wrong - missing quotes
whereClause: "ofType(AlarmConditionType)"

// ✅ Correct
whereClause: "ofType('AlarmConditionType')"

// ❌ Wrong - wrong operator
whereClause: "Severity => 600"

// ✅ Correct
whereClause: "Severity >= 600"

// ❌ Wrong - invalid logical operator
whereClause: "Severity >= 600 && ofType('AlarmConditionType')"

// ✅ Correct
whereClause: "Severity >= 600 AND ofType('AlarmConditionType')"

2. Unknown Event Types

Problem: Event type name doesn't exist

Solution:

// Use standard OPC UA event types
ofType('BaseEventType')
ofType('SystemEventType')
ofType('AlarmConditionType')
ofType('AuditEventType')

// For custom types, verify exact name with server documentation

3. Field Name Errors

Problem: Using field names that don't exist in Where Clause

Solution:

// Only use standard event fields in Where Clause
// EventId, EventType, SourceName, Time, Message, Severity

// ✅ Valid
whereClause: "Severity >= 600"
whereClause: "SourceName = 'Reactor1'"

// ❌ Invalid - field doesn't exist in Where Clause context
whereClause: "ActiveState = true"

Memory Issues

Symptom

Node-RED becomes slow, crashes, or shows high memory usage when monitoring events.

Possible Causes & Solutions

1. Too Many Events Buffered

Problem: Events accumulating faster than they're processed

Solution:

// Add rate limiting
const maxEvents = 1000;
const events = context.get('events') || [];

if (events.length >= maxEvents) {
node.warn('Event buffer full, dropping oldest');
events.shift(); // Remove oldest
}

events.push(msg.payload);
context.set('events', events);

2. Large Context Storage

Problem: Storing too much data in context

Solution:

// Limit context storage
const stats = flow.get('stats') || {};

// Keep only recent data
const maxEntries = 1000;
const keys = Object.keys(stats);
if (keys.length > maxEntries) {
// Remove oldest half
keys.slice(0, maxEntries / 2).forEach(key => {
delete stats[key];
});
}

flow.set('stats', stats);

3. Memory Leaks

Problem: Objects not being garbage collected

Solution:

// Clear old data periodically
const clearInterval = 3600000; // 1 hour
const lastClear = flow.get('lastClear') || 0;
const now = Date.now();

if (now - lastClear > clearInterval) {
// Clear old context data
flow.set('eventCache', {});
flow.set('statistics', {});
flow.set('lastClear', now);
node.log('Cleared old event data');
}

Getting Help

If you continue experiencing issues:

  1. Check Node-RED Logs:

    • Look for error messages
    • Check connection status
    • Review subscription errors
  2. Enable Debug Logging:

    • Add debug nodes at each step
    • Log context variables
    • Track event flow
  3. Test with Simple Configuration:

    • Remove Where Clause
    • Use basic Select Clause
    • Monitor Server object (i=2253)
  4. Verify Server Support:

    • Check server documentation
    • Test with another OPC UA client
    • Contact server vendor
  5. Community Resources:

    • Node-RED forum
    • OPC UA community
    • GitHub issues

Next Steps

See Also