mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
fix: 'uc image push' closed network connection error if takes >10s (fixes #141)
This commit is contained in:
@@ -81,10 +81,11 @@ func (p *Proxy) handleConnection(ctx context.Context, localConn net.Conn) {
|
|||||||
defer p.activeConns.Done()
|
defer p.activeConns.Done()
|
||||||
defer localConn.Close()
|
defer localConn.Close()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
// Use a separate context with timeout for dialing the remote address.
|
||||||
|
dialCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
remoteConn, err := p.DialContext(ctx, "tcp", p.RemoteAddr)
|
remoteConn, err := p.DialContext(dialCtx, "tcp", p.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if p.OnError != nil {
|
if p.OnError != nil {
|
||||||
p.OnError(fmt.Errorf("connect remote address '%s': %w", p.RemoteAddr, err))
|
p.OnError(fmt.Errorf("connect remote address '%s': %w", p.RemoteAddr, err))
|
||||||
|
|||||||
Reference in New Issue
Block a user