Skip to content

Commit

Permalink
Revert "Optimize HTTP timeout"
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol authored Mar 13, 2024
1 parent 4cd993e commit 239b96a
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions mp4_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,14 @@ import (
"log"
"m3u-stream-merger/database"
"m3u-stream-merger/utils"
"net"
"net/http"
"os"
"strconv"
"strings"
"syscall"
"time"
)

func loadBalancer(stream database.StreamInfo) (resp *http.Response, selectedUrl *database.StreamURL, err error) {
netTransport := &http.Transport{
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
}).Dial,
TLSHandshakeTimeout: 5 * time.Second,
}
httpClient := &http.Client{
Timeout: time.Second * 10,
Transport: netTransport,
}

loadBalancingMode := os.Getenv("LOAD_BALANCING_MODE")
if loadBalancingMode == "" {
loadBalancingMode = "brute-force"
Expand All @@ -52,7 +39,7 @@ func loadBalancer(stream database.StreamInfo) (resp *http.Response, selectedUrl
continue // Skip this stream if concurrency limit reached
}

resp, err = httpClient.Get(url.Content)
resp, err = http.Get(url.Content)
if err == nil {
selectedUrl = &url
break
Expand All @@ -75,7 +62,7 @@ func loadBalancer(stream database.StreamInfo) (resp *http.Response, selectedUrl
continue // Skip this stream if concurrency limit reached
}

resp, err = httpClient.Get(url.Content)
resp, err = http.Get(url.Content)
if err == nil {
selectedUrl = &url
break
Expand All @@ -92,7 +79,7 @@ func loadBalancer(stream database.StreamInfo) (resp *http.Response, selectedUrl
log.Printf("All concurrency limits have been reached. Falling back to connection checking mode...\n")
// Connection check mode
for _, url := range stream.URLs {
resp, err = httpClient.Get(url.Content)
resp, err = http.Get(url.Content)
if err == nil {
selectedUrl = &url
break
Expand Down

0 comments on commit 239b96a

Please sign in to comment.