Skip to content

Commit 11e6ba9

Browse files
author
eduard256
committed
Merge develop: Fix SSE timeout issues
2 parents 12770ed + a6e9cc2 commit 11e6ba9

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

internal/camera/discovery/scanner.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,26 +409,20 @@ func (s *Scanner) testStreamsConcurrently(ctx context.Context, streams []models.
409409
defer cancelProgress()
410410

411411
go func() {
412-
ticker := time.NewTicker(3 * time.Second)
412+
ticker := time.NewTicker(1 * time.Second)
413413
defer ticker.Stop()
414414

415-
lastTested := int32(0)
416-
417415
for {
418416
select {
419417
case <-progressCtx.Done():
420418
return
421419
case <-ticker.C:
422-
currentTested := atomic.LoadInt32(&tested)
423-
// Only send if there's been progress
424-
if currentTested != lastTested {
425-
_ = streamWriter.SendJSON("progress", models.ProgressMessage{
426-
Tested: int(currentTested),
427-
Found: int(atomic.LoadInt32(&found)),
428-
Remaining: len(streams) - int(currentTested),
429-
})
430-
lastTested = currentTested
431-
}
420+
// Send progress every second to prevent WriteTimeout
421+
_ = streamWriter.SendJSON("progress", models.ProgressMessage{
422+
Tested: int(atomic.LoadInt32(&tested)),
423+
Found: int(atomic.LoadInt32(&found)),
424+
Remaining: len(streams) - int(atomic.LoadInt32(&tested)),
425+
})
432426
}
433427
}
434428
}()

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Load() *Config {
7373
Server: ServerConfig{
7474
Listen: ":4567", // Default listen address
7575
ReadTimeout: 30 * time.Second,
76-
WriteTimeout: 30 * time.Second,
76+
WriteTimeout: 5 * time.Minute, // Increased for SSE long-polling
7777
},
7878
Database: DatabaseConfig{
7979
DataPath: dataPath,

0 commit comments

Comments
 (0)