Skip to content

Commit 0367430

Browse files
committed
added timeouts for gateway health checks
1 parent bf5a44e commit 0367430

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mcpgateway/services/gateway_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,12 @@ async def check_health_of_gateways(self, gateways: List[DbGateway]) -> bool:
576576

577577
# Perform the GET and raise on 4xx/5xx
578578
if (gateway.transport).lower() == "sse":
579-
async with client.stream("GET", gateway.url, headers=headers) as response:
579+
timeout = httpx.Timeout(settings.health_check_timeout)
580+
async with client.stream("GET", gateway.url, headers=headers,timeout=timeout) as response:
580581
# This will raise immediately if status is 4xx/5xx
581582
response.raise_for_status()
582583
elif (gateway.transport).lower() == "streamablehttp":
583-
async with streamablehttp_client(url=gateway.url, headers=headers, timeout=5) as (read_stream, write_stream, get_session_id):
584+
async with streamablehttp_client(url=gateway.url, headers=headers, timeout=settings.health_check_timeout) as (read_stream, write_stream, get_session_id):
584585
async with ClientSession(read_stream, write_stream) as session:
585586
# Initialize the session
586587
response = await session.initialize()

0 commit comments

Comments
 (0)