diff --git a/apps/proxy/vod_proxy/connection_manager.py b/apps/proxy/vod_proxy/connection_manager.py index 7e8cce1f..1ae1a656 100644 --- a/apps/proxy/vod_proxy/connection_manager.py +++ b/apps/proxy/vod_proxy/connection_manager.py @@ -281,6 +281,13 @@ class VODConnectionManager: profile_connections_key = self._get_profile_connections_key(m3u_profile.id) content_connections_key = self._get_content_connections_key(content_type, content_uuid) + # Check if connection already exists to prevent duplicate counting + if self.redis_client.exists(connection_key): + logger.info(f"Connection already exists for {client_id} - {content_type} {content_name}") + # Update activity but don't increment profile counter + self.redis_client.hset(connection_key, "last_activity", str(time.time())) + return True + # Connection data connection_data = { "content_type": content_type, diff --git a/apps/proxy/vod_proxy/views.py b/apps/proxy/vod_proxy/views.py index 4db4037a..f5eded02 100644 --- a/apps/proxy/vod_proxy/views.py +++ b/apps/proxy/vod_proxy/views.py @@ -156,15 +156,7 @@ class VODStreamView(View): logger.info(f"[VOD-PROFILE] Using M3U profile: {m3u_profile.id} (max_streams: {m3u_profile.max_streams}, current: {m3u_profile.current_viewers})") - # Track connection in Redis (simplified) - try: - from core.utils import RedisClient - redis_client = RedisClient.get_client() - profile_connections_key = f"profile_connections:{m3u_profile.id}" - redis_client.incr(profile_connections_key) - except Exception as e: - logger.error(f"Error tracking connection in Redis: {e}") - + # Connection tracking is handled by the connection manager # Transform URL based on profile final_stream_url = self._transform_url(stream_url, m3u_profile) logger.info(f"[VOD-URL] Final stream URL: {final_stream_url}")