Overview
Forge provides WebSocket endpoints for real-time updates on process execution, task attempts, and system events. WebSocket Base URL:ws://localhost:8887/ws
Connection Basics
Establishing Connection
Authentication
WebSocket connections use the same GitHub OAuth authentication as REST API:Process Log Streaming
Raw Logs Stream
Stream unprocessed output from execution processes.Normalized Logs Stream
Stream structured, processed log messages.debug- Detailed diagnostic informationinfo- General informational messageswarn- Warning messageserror- Error messagessuccess- Success/completion messages
Process Status Streaming
Monitor all execution processes in real-time.process_started
process_progress
process_completed
process_failed
process_stopped
Task Attempt Diff Streaming
Stream git diff updates as task attempt progresses.Advanced Usage
Reconnection Strategy
Implement automatic reconnection for production use:Heartbeat / Keep-Alive
Maintain connection with periodic heartbeat:Message Buffering
Buffer messages when connection is unavailable:SDK Integration
JavaScript/TypeScript
Python
Best Practices
Handle Connection Failures
Handle Connection Failures
Always implement reconnection logic and handle connection failures gracefully:
Clean Up Resources
Clean Up Resources
Close WebSocket connections when no longer needed:
Use Structured Logs
Use Structured Logs
Prefer normalized logs over raw logs for easier parsing:
Monitor Connection Health
Monitor Connection Health
Implement heartbeat to detect stale connections:
Troubleshooting
Connection Refused
Error:WebSocket connection to 'ws://localhost:8887/ws/...' failed
Solutions:
- Verify Forge backend is running
- Check firewall allows WebSocket connections
- Ensure port 8080 is not blocked
- Try HTTP upgrade instead of direct WebSocket
Unexpected Disconnections
Issue: WebSocket disconnects frequently Solutions:- Implement heartbeat/ping-pong
- Check network stability
- Increase timeout settings
- Use reconnection strategy
Missing Messages
Issue: Not receiving all events Solutions:- Check message handler for errors
- Verify WebSocket is in OPEN state before sending
- Implement message buffering
- Check server-side logs

