From 4f3862fd875086e3dd88e118aab5a0c9b40ae65b Mon Sep 17 00:00:00 2001 From: Lin <36601667+buhuang28@users.noreply.github.com> Date: Thu, 6 Jan 2022 20:52:09 +0800 Subject: [PATCH] fix socket block (#236) --- client/internal/highway/highway.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/internal/highway/highway.go b/client/internal/highway/highway.go index 638d5a79..0e74b5a8 100644 --- a/client/internal/highway/highway.go +++ b/client/internal/highway/highway.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "sync/atomic" + "time" "github.com/pkg/errors" @@ -48,7 +49,7 @@ type Input struct { func (s *Session) Upload(addr Addr, input Input) error { fh, length := utils.ComputeMd5AndLength(input.Body) _, _ = input.Body.Seek(0, io.SeekStart) - conn, err := net.DialTCP("tcp", nil, addr.asTcpAddr()) + conn, err := net.DialTimeout("tcp", addr.String(), time.Second*3) if err != nil { return errors.Wrap(err, "connect error") }