Overview
The messaging infrastructure provides real-time communication between clients and the ElizaOS server using Socket.IO. This enables instant message delivery, presence tracking, and bidirectional communication.Architecture
How WebSockets Work in ElizaOS
The project uses Socket.IO (not raw WebSockets) for real-time communication between clients and the Eliza server.Key Components
- Direct Connection: Socket.IO connects directly to the Eliza server (default:
http://localhost:3000
) - Channel-Based Communication: Messages are organized by channels (or rooms for backward compatibility)
- Message Filtering: Clients filter incoming broadcasts by channel/room ID
Socket.IO Events and Message Types
Message Types Enum
Key Events
messageBroadcast
- Incoming messages from agents/usersmessageComplete
- Message processing completecontrolMessage
- UI control (enable/disable input)connection_established
- Connection confirmed
Socket.IO Client Implementation
Minimal Socket.IO Client
Here’s a minimal Socket.IO client implementation:Modern Implementation (Socket.IO v4.x)
For newer Socket.IO versions, here’s a cleaner implementation:Key Points to Check
1. Event Name
2. Room Joining Required
3. Exact Message Format
Complete Message Flow
- Client connects → Server accepts connection
- Client joins room → Server adds client to room
- Client sends message → Server receives and processes
- Server broadcasts response → All clients in room receive
- Clients filter by room ID → Only relevant messages shown
Debugging Steps
1. Verify Events
2. Check Room ID
- Ensure the room ID matches exactly between your extension and the server
- Even a single character difference will prevent message delivery
3. CORS Issues
For browser extensions, ensure your manifest includes:4. Transport Issues
If WebSocket fails, force polling:Socket.IO Version Compatibility
Version Issues
- v1.3.0 (2015) - Very old, may have compatibility issues
- v4.x (Current) - Recommended for new implementations
Upgrading
Common Mistakes
- Wrong event name - Using
message
instead ofmessageBroadcast
- Not joining room - Forgetting the
ROOM_JOINING
step - ID mismatch - Room/channel IDs don’t match exactly
- Missing fields - Payload missing required fields
- CORS blocked - Extension lacks permissions
Testing Your Implementation
- Open browser console
- Check for connection logs
- Verify room join confirmation
- Send test message
- Check for broadcast reception
Common Issue: Extension Not Receiving Responses
The Problem
Your extension can send messages to Eliza (server receives them), but doesn’t receive responses back.Root Causes
- Not listening for the correct event - Must listen for
messageBroadcast
, notmessage
- Not joining the room/channel - Must emit a
ROOM_JOINING
message first - Room/Channel ID mismatch - IDs must match exactly
- Incorrect message payload structure
Solution Checklist
- Verify you’re listening to
messageBroadcast
event - Ensure you join the room on connection
- Check room ID matches exactly
- Verify message payload structure
- Check browser console for errors
- Test with debug logging enabled
Advanced Features
Presence Tracking
Typing Indicators
Message Acknowledgments
Server-Side Implementation
The Socket.IO server handles message routing and broadcasting:Reference Implementation
Eliza NextJS Starter
A complete working example demonstrating Socket.IO integration with Eliza, including real-time messaging, agent participation management, and comprehensive error handling.