Fix SSE real-time streaming in Home Assistant Ingress mode
Add padding to overcome aiohttp 64KB buffer in HA Supervisor. Problem: - HA Supervisor uses aiohttp with 64KB StreamResponse buffer - Small SSE events (~200-500 bytes) were buffered until connection closed - Users saw all streams appear at once instead of real-time updates Solution: - Detect Ingress mode via X-Ingress-Path header - Add 64KB SSE comment padding to fill proxy buffers - Increase progress interval to 3 sec in Ingress mode (reduce traffic) - Normal mode (Docker/direct) unchanged - works exactly as before Traffic impact: - Normal mode: ~17KB per scan (unchanged) - Ingress mode: ~2-3MB per scan (acceptable for real-time updates) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -411,7 +411,14 @@ func (s *Scanner) testStreamsConcurrently(ctx context.Context, streams []models.
|
||||
defer cancelProgress()
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
// Use longer interval for Ingress mode to reduce traffic (padding is ~64KB per event)
|
||||
// Normal mode: 1 second, Ingress mode: 3 seconds
|
||||
progressInterval := 1 * time.Second
|
||||
if streamWriter.IsIngress() {
|
||||
progressInterval = 3 * time.Second
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(progressInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
@@ -419,7 +426,7 @@ func (s *Scanner) testStreamsConcurrently(ctx context.Context, streams []models.
|
||||
case <-progressCtx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
// Send progress every second to prevent WriteTimeout
|
||||
// Send progress to prevent WriteTimeout and show scanning activity
|
||||
_ = streamWriter.SendJSON("progress", models.ProgressMessage{
|
||||
Tested: int(atomic.LoadInt32(&tested)),
|
||||
Found: int(atomic.LoadInt32(&found)),
|
||||
|
||||
Reference in New Issue
Block a user