From ded4b08113596f1e3936462f2737199f062b281c Mon Sep 17 00:00:00 2001 From: Yeganathan S Date: Thu, 12 May 2022 06:18:05 +0000 Subject: [PATCH] fix(ndt7): discards all incoming websockets messages during upload (#719) See https://github.com/ooni/probe/issues/2084 --- internal/engine/experiment/ndt7/upload.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/engine/experiment/ndt7/upload.go b/internal/engine/experiment/ndt7/upload.go index 26637c9..f45b3fb 100644 --- a/internal/engine/experiment/ndt7/upload.go +++ b/internal/engine/experiment/ndt7/upload.go @@ -52,6 +52,15 @@ func (mgr uploadManager) run(ctx context.Context) error { } ticker := time.NewTicker(mgr.measureInterval) defer ticker.Stop() + // goroutine that just reads and discards all incoming websockets messages + go func() { + for { + _, _, err := mgr.conn.NextReader() + if err != nil { + return + } + } + }() for ctx.Err() == nil { if err := mgr.conn.WritePreparedMessage(message); err != nil { return err