Skip to content

Commit 09d5485

Browse files
committed
fix: Provider profiles refresh and timeouts
Why This Fixes The Blocking: No More Connection Bursts: Provider sees gradual connections over 15-100 seconds instead of a sudden spike Unpredictable Timing: Random jitter prevents providers from detecting automated patterns
1 parent 6ab1bf1 commit 09d5485

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/Jobs/RefreshPlaylistProfiles.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ protected function refreshPlaylistProfiles(Playlist $playlist): void
101101
foreach ($profiles as $profile) {
102102
$this->refreshProfile($profile);
103103

104-
// Add a small delay between API calls to avoid rate limiting
105-
usleep(500000); // 500ms
104+
// Add a delay between API calls to avoid overwhelming the provider
105+
// Random delay between 3-5 seconds to prevent burst patterns
106+
$delayMicroseconds = rand(3000000, 5000000); // 3-5 seconds
107+
usleep($delayMicroseconds);
106108
}
107109
}
108110

app/Services/M3uProxyService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static function getPlaylistActiveStreamsCount($playlist): int
159159

160160
try {
161161
$endpoint = $service->apiBaseUrl.'/streams/by-metadata';
162-
$response = Http::timeout(10)->acceptJson()
162+
$response = Http::timeout(5)->acceptJson()
163163
->withHeaders($service->apiToken ? [
164164
'X-API-Token' => $service->apiToken,
165165
] : [])
@@ -204,7 +204,7 @@ public static function getPlaylistActiveStreams($playlist, int $retries = 2): ?a
204204

205205
while ($attempt < $retries) {
206206
try {
207-
$response = Http::timeout(10)->acceptJson()
207+
$response = Http::timeout(5)->acceptJson()
208208
->withHeaders($service->apiToken ? [
209209
'X-API-Token' => $service->apiToken,
210210
] : [])
@@ -265,7 +265,7 @@ public static function isChannelActive(Channel $channel): bool
265265

266266
try {
267267
$endpoint = $service->apiBaseUrl.'/streams/by-metadata';
268-
$response = Http::timeout(10)->acceptJson()
268+
$response = Http::timeout(5)->acceptJson()
269269
->withHeaders($service->apiToken ? [
270270
'X-API-Token' => $service->apiToken,
271271
] : [])
@@ -311,7 +311,7 @@ public static function getActiveStreamsCountByMetadata(string $field, string $va
311311

312312
try {
313313
$endpoint = $service->apiBaseUrl.'/streams/by-metadata';
314-
$response = Http::timeout(10)->acceptJson()
314+
$response = Http::timeout(5)->acceptJson()
315315
->withHeaders($service->apiToken ? [
316316
'X-API-Token' => $service->apiToken,
317317
] : [])

0 commit comments

Comments
 (0)