rpcclient: add http timeout

This commit is contained in:
ziggie 2024-10-10 10:05:01 +02:00
parent 67b8efd3ba
commit 44c874f9f6
No known key found for this signature in database
GPG Key ID: 1AFF9C4DCED6D666

View File

@ -92,6 +92,10 @@ const (
// requestRetryInterval is the initial amount of time to wait in between // requestRetryInterval is the initial amount of time to wait in between
// retries when sending HTTP POST requests. // retries when sending HTTP POST requests.
requestRetryInterval = time.Millisecond * 500 requestRetryInterval = time.Millisecond * 500
// defaultHTTPTimeout is the default timeout for an http request, so the
// request does not block indefinitely.
defaultHTTPTimeout = time.Minute
) )
// jsonRequest holds information about a json request that is used to properly // jsonRequest holds information about a json request that is used to properly
@ -1363,6 +1367,7 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) {
return net.Dial(parsedAddr.Network(), parsedAddr.String()) return net.Dial(parsedAddr.Network(), parsedAddr.String())
}, },
}, },
Timeout: defaultHTTPTimeout,
} }
return &client, nil return &client, nil