Skip to content

Commit

Permalink
Add 3-minute client timeout to HTTP requests by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Mar 2, 2021
1 parent 484a312 commit 281bbc7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func DiscoverClientAPI(serverName string) (*ClientWellKnown, error) {

req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1218,7 +1219,7 @@ func NewClient(homeserverURL string, userID id.UserID, accessToken string) (*Cli
UserAgent: "mautrix-go " + Version,
HomeserverURL: hsURL,
UserID: userID,
Client: http.DefaultClient,
Client: &http.Client{Timeout: 180 * time.Second},
Prefix: URLPath{"_matrix", "client", "r0"},
Syncer: NewDefaultSyncer(),
// By default, use an in-memory store which will never save filter ids / next batch tokens to disk.
Expand Down

0 comments on commit 281bbc7

Please sign in to comment.