diff --git a/sender_worker.go b/sender_worker.go index b01bb62..5a705fa 100644 --- a/sender_worker.go +++ b/sender_worker.go @@ -8,12 +8,14 @@ import ( "log" "net/http" "sync" + "time" "git.sr.ht/~michalr/go-satel" ) const ( NotificationPartitionIndex = 0 + httpTimeout = 1 * time.Second ) type Sender interface { @@ -61,7 +63,10 @@ func doHttpNotification(url string, logger *log.Logger, wg *sync.WaitGroup) { } req, err := http.NewRequest(http.MethodPost, url, nil) - res, err := http.DefaultClient.Do(req) + client := http.Client{ + Timeout: httpTimeout, + } + res, err := client.Do(req) if err != nil { logger.Print("Could not POST ", url, ": ", err) return @@ -139,7 +144,10 @@ func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config } req, err := http.NewRequest(http.MethodPost, matterbridgeConfig.URI, bytes.NewBuffer(body)) req.Header["Authorization"] = []string{fmt.Sprint("Bearer ", matterbridgeConfig.Token)} - res, err := http.DefaultClient.Do(req) + client := http.Client{ + Timeout: httpTimeout, + } + res, err := client.Do(req) if err != nil { logger.Print("Could not POST ", matterbridgeConfig.URI, ": ", err) return