Skip to content

Commit

Permalink
fix(birdweather): Increase HTTP timeout to 45 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
tphakala committed Apr 28, 2024
1 parent e89b00e commit 56b3f11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/birdweather/birdweather.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func New(settings *conf.Settings) *BwClient {
BirdweatherID: settings.Realtime.Birdweather.ID,
Latitude: settings.BirdNET.Latitude,
Longitude: settings.BirdNET.Longitude,
HTTPClient: &http.Client{Timeout: 5 * time.Second},
HTTPClient: &http.Client{Timeout: 45 * time.Second},
}
}

Expand Down Expand Up @@ -83,6 +83,7 @@ func (b *BwClient) UploadSoundscape(timestamp string, pcmData []byte) (soundscap
req.Header.Set("Content-Encoding", "gzip")
req.Header.Set("User-Agent", "BirdNET-Go")

// Execute the request
resp, err := b.HTTPClient.Do(req)
if err != nil {
log.Printf("Request to upload soundscape failed: %v\n", err)
Expand Down Expand Up @@ -158,6 +159,7 @@ func (b *BwClient) PostDetection(soundscapeID, timestamp, commonName, scientific
Confidence: fmt.Sprintf("%.2f", confidence),
}

// Marshal JSON data
postDataBytes, err := json.Marshal(postData)
if err != nil {
log.Printf("Failed to marshal JSON data, err: %v\n", err)
Expand Down

0 comments on commit 56b3f11

Please sign in to comment.