Skip to content

Commit f3ef334

Browse files
authored
Fix DiagnosticVM, force ipv4 connexion on /internet check (#760)
This fix issue reported by node owner where if they enable a ipv6 and it's not working, it also break the diagnostic /internet check
1 parent 6055ad6 commit f3ef334

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/example_fastapi/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ async def connect_ipv6():
198198
return {"result": False, "reason": str(error.args[0])}
199199

200200

201-
async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5):
201+
async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5, socket_family=socket.AF_INET):
202202
"""Check the connectivity of a single URL."""
203203
timeout = aiohttp.ClientTimeout(total=timeout_seconds)
204-
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(), timeout=timeout) as session:
204+
tcp_connector = aiohttp.TCPConnector(family=socket_family)
205+
async with aiohttp.ClientSession(timeout=timeout, connector=tcp_connector) as session:
205206
try:
206207
async with session.get(internet_host) as resp:
207208
resp.raise_for_status()

0 commit comments

Comments
 (0)