WebSocket Support
Configure WebSocket endpoints in moclojer for real-time bidirectional communication. Perfect for mocking chat applications, live notifications, and collaborative features.
🎯 How WebSockets Work in moclojer
sequenceDiagram
participant Client
participant moclojer
Client->>moclojer: WebSocket Handshake (HTTP Upgrade)
moclojer->>Client: 101 Switching Protocols
Note over moclojer,Client: WebSocket Connection Established
moclojer->>Client: on-connect message
loop Message Exchange
Client->>moclojer: Send message
Note over moclojer: Pattern matching
moclojer->>Client: Response (if pattern matches)
end
Client->>moclojer: Close connection
moclojer->>Client: Connection closed📝 Basic Configuration
Simple Echo Server
🔧 WebSocket Configuration
Required Fields
Field
Description
Optional Fields
Field
Description
Default
Message Pattern Matching
Field
Description
💬 Chat Application
🔔 Real-Time Notifications
📊 Live Dashboard Updates
🎮 Game Server
🧪 Testing WebSockets
Using websocat (Recommended)
Using wscat
JavaScript/Browser Test
Python Test
📝 Using Template Variables
Available Template Variables
Variable
Description
Example
✅ Best Practices
🔧 Advanced Patterns
Multi-Pattern Matching
Conditional Responses
🚨 Important Notes
📊 Use Cases
Scenario
Configuration
🔍 Debugging WebSockets
Enable Verbose Logging
Monitor Traffic with Browser DevTools
Common Issues
Issue
Solution
📚 See Also
Last updated
Was this helpful?