Skip to content

Commit

Permalink
rpcclient: add timeout for http request.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggie1984 committed Oct 2, 2024
1 parent 67b8efd commit 4a14e53
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpcclient/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Second * 10
)

// jsonRequest holds information about a json request that is used to properly
Expand Down Expand Up @@ -1363,6 +1367,7 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) {
return net.Dial(parsedAddr.Network(), parsedAddr.String())
},
},
Timeout: defaultHTTPTimeout,
}

return &client, nil
Expand Down

0 comments on commit 4a14e53

Please sign in to comment.