From 44c874f9f6ed650f288269a34108e1cbf755b89e Mon Sep 17 00:00:00 2001 From: ziggie Date: Thu, 10 Oct 2024 10:05:01 +0200 Subject: [PATCH] rpcclient: add http timeout --- rpcclient/infrastructure.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 891b517195..eaa050a735 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -92,6 +92,10 @@ const ( // requestRetryInterval is the initial amount of time to wait in between // retries when sending HTTP POST requests. 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 @@ -1363,6 +1367,7 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) { return net.Dial(parsedAddr.Network(), parsedAddr.String()) }, }, + Timeout: defaultHTTPTimeout, } return &client, nil