Back out matrix-org/dendrite#2421 by restoring http.Clients

This creates problems with non-HTTPS endpoints and should fix #2444.
This commit is contained in:
Neil Alexander 2022-05-10 11:08:10 +01:00
parent 1b3fa9689c
commit 77722c5a4f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
6 changed files with 44 additions and 33 deletions

View file

@ -39,7 +39,7 @@ type phoneHomeStats struct {
cfg *config.Dendrite
db storage.Statistics
isMonolith bool
client *gomatrixserverlib.Client
client *http.Client
}
type timestampToRUUsage struct {
@ -55,9 +55,10 @@ func StartPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, statsDB
cfg: cfg,
db: statsDB,
isMonolith: cfg.IsMonolith,
client: gomatrixserverlib.NewClient(
gomatrixserverlib.WithTimeout(time.Second * 30),
),
client: &http.Client{
Timeout: time.Second * 30,
Transport: http.DefaultTransport,
},
}
// start initial run after 5min
@ -151,7 +152,8 @@ func (p *phoneHomeStats) collect() {
}
request.Header.Set("User-Agent", "Dendrite/"+internal.VersionString())
if _, err = p.client.DoHTTPRequest(ctx, request); err != nil {
_, err = p.client.Do(request)
if err != nil {
logrus.WithError(err).Error("unable to send anonymous stats")
return
}