From 694f63970e2b981aec6406400fa93e2c6aeafdd6 Mon Sep 17 00:00:00 2001 From: jsun-m <91754185+jsun-m@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:38:20 -0700 Subject: [PATCH] Fix: Client websocket connection hangs when server disconnects (#657) ``` _, err := io.Copy(src, dst) ``` io.Copy doesn't automatically fail when `src` connection closes. This change guarantees that when at least connection fails (either src, dst) the other one also disconnects --- pkg/abstractions/endpoint/buffer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/abstractions/endpoint/buffer.go b/pkg/abstractions/endpoint/buffer.go index 604a2ba08..5d50818fd 100644 --- a/pkg/abstractions/endpoint/buffer.go +++ b/pkg/abstractions/endpoint/buffer.go @@ -558,6 +558,11 @@ func (rb *RequestBuffer) proxyWebsocketConnection(r *request, c container, diale } func forwardWSConn(src net.Conn, dst net.Conn) { + defer func() { + src.Close() + dst.Close() + }() + _, err := io.Copy(src, dst) if err != nil { return