mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
hicli: lower http header timeout after first sync
This commit is contained in:
parent
cc4eb16c7c
commit
5189f86f81
3 changed files with 15 additions and 4 deletions
|
@ -226,6 +226,10 @@ func (gmx *Gomuks) DownloadMedia(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
resp, err := gmx.Client.Client.Download(ctx, mxc)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
w.WriteHeader(499)
|
||||
return
|
||||
}
|
||||
log.Err(err).Msg("Failed to download media")
|
||||
var httpErr mautrix.HTTPError
|
||||
if cacheEntry == nil {
|
||||
|
@ -236,6 +240,7 @@ func (gmx *Gomuks) DownloadMedia(w http.ResponseWriter, r *http.Request) {
|
|||
if cacheEntry.Error == nil {
|
||||
cacheEntry.Error = &database.MediaError{
|
||||
ReceivedAt: jsontime.UnixMilliNow(),
|
||||
Attempts: 1,
|
||||
}
|
||||
} else {
|
||||
cacheEntry.Error.Attempts++
|
||||
|
|
|
@ -94,11 +94,12 @@ func New(rawDB, cryptoDB *dbutil.Database, log zerolog.Logger, pickleKey []byte,
|
|||
Transport: &http.Transport{
|
||||
DialContext: (&net.Dialer{Timeout: 10 * time.Second}).DialContext,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
// This needs to be relatively high to allow initial syncs
|
||||
ResponseHeaderTimeout: 180 * time.Second,
|
||||
// This needs to be relatively high to allow initial syncs,
|
||||
// it's lowered after the first sync in postProcessSyncResponse
|
||||
ResponseHeaderTimeout: 300 * time.Second,
|
||||
ForceAttemptHTTP2: true,
|
||||
},
|
||||
Timeout: 180 * time.Second,
|
||||
Timeout: 300 * time.Second,
|
||||
},
|
||||
Syncer: (*hiSyncer)(c),
|
||||
Store: (*hiStore)(c),
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -70,7 +71,11 @@ func (h *HiClient) postProcessSyncResponse(ctx context.Context, resp *mautrix.Re
|
|||
if syncCtx.shouldWakeupRequestQueue {
|
||||
h.WakeupRequestQueue()
|
||||
}
|
||||
h.firstSyncReceived = true
|
||||
if !h.firstSyncReceived {
|
||||
h.firstSyncReceived = true
|
||||
h.Client.Client.Transport.(*http.Transport).ResponseHeaderTimeout = 60 * time.Second
|
||||
h.Client.Client.Timeout = 180 * time.Second
|
||||
}
|
||||
if !syncCtx.evt.IsEmpty() {
|
||||
h.EventHandler(syncCtx.evt)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue