The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
[Partner Nodes] fix(client): respect proxy environment variables (#17346)
Alexander Piskun0b05cd8a3683
diff --git a/comfy_api_nodes/nodes_sonilo.py b/comfy_api_nodes/nodes_sonilo.pyindex 7aba8970c..5829c3ccf 100644--- a/comfy_api_nodes/nodes_sonilo.py+++ b/comfy_api_nodes/nodes_sonilo.py@@ -177,7 +177,7 @@ async def _stream_sonilo_music(title: str | None = Nonetimeout = aiohttp.ClientTimeout(total=1200.0, sock_read=300.0)- async with aiohttp.ClientSession(timeout=timeout) as session:+ async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:PromptServer.instance.send_progress_text("Status: Queued", node_id)async with session.post(url, data=form, headers=headers) as resp:if resp.status >= 400:diff --git a/comfy_api_nodes/nodes_topaz.py b/comfy_api_nodes/nodes_topaz.pyindex d8d051224..173ed99ef 100644--- a/comfy_api_nodes/nodes_topaz.py+++ b/comfy_api_nodes/nodes_topaz.py@@ -779,7 +779,7 @@ class TopazVideoEnhance(IO.ComfyNode):raise NotImplementedError("Large files are not currently supported. Please open an issue in the ComfyUI repository.")- async with aiohttp.ClientSession(headers={"Content-Type": "video/mp4"}) as session:+ async with aiohttp.ClientSession(headers={"Content-Type": "video/mp4"}, trust_env=True) as session:if isinstance(src_video_stream, BytesIO):src_video_stream.seek(0)async with session.put(upload_res.urls[0], data=src_video_stream, raise_for_status=True) as res:@@ -1122,7 +1122,7 @@ class TopazVideoEnhanceV2(IO.ComfyNode):raise NotImplementedError("Large files are not currently supported. Please open an issue in the ComfyUI repository.")- async with aiohttp.ClientSession(headers={"Content-Type": "video/mp4"}) as session:+ async with aiohttp.ClientSession(headers={"Content-Type": "video/mp4"}, trust_env=True) as session:if isinstance(src_video_stream, BytesIO):src_video_stream.seek(0)async with session.put(upload_res.urls[0], data=src_video_stream, raise_for_status=True) as res:diff --git a/comfy_api_nodes/util/_helpers.py b/comfy_api_nodes/util/_helpers.pyindex 9a051e1d9..4f5a883b2 100644--- a/comfy_api_nodes/util/_helpers.py+++ b/comfy_api_nodes/util/_helpers.py@@ -106,7 +106,7 @@ async def _request_partner_token_renewal(lineage: str, sid: str, token: str) ->if is_processing_interrupted():return Nonetry:- async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=max(deadline - time.monotonic(), 1.0))) as session:+ async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=max(deadline - time.monotonic(), 1.0)), trust_env=True) as session:async with session.post(url, headers={"Authorization": f"Bearer {token}"}) as resp:if 400 <= resp.status < 500:logging.warning("Comfy API refused to renew the sign-in token (HTTP %s).", resp.status)@@ -249,7 +249,7 @@ async def diagnose_connectivity() -> dict[str, bool]:# to correctly detect that Chinese users with working internet do have working internet.internet_probe_urls = ("https://www.google.com", "https://www.baidu.com")- async with aiohttp.ClientSession(timeout=timeout) as session:+ async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:async def _probe(url: str) -> bool:try:async with session.get(url) as resp:diff --git a/comfy_api_nodes/util/client.py b/comfy_api_nodes/util/client.pyindex df02c214c..e316e97c5 100644--- a/comfy_api_nodes/util/client.py+++ b/comfy_api_nodes/util/client.py@@ -937,7 +937,7 @@ async def _request_base(cfg: _RequestConfig, expect_binary: bool):monitor_task = asyncio.create_task(_monitor(stop_event, start_time))timeout = aiohttp.ClientTimeout(total=cfg.timeout)- sess = aiohttp.ClientSession(timeout=timeout)+ sess = aiohttp.ClientSession(timeout=timeout, trust_env=True)if cfg.content_type == "multipart/form-data" and method != "GET":payload_headers.pop("Content-Type", None)@@ -1213,7 +1213,7 @@ async def _request_base(cfg: _RequestConfig, expect_binary: bool):)raise LocalNetworkError("Unable to connect to the API server due to local network issues. "- "Please check your internet connection and try again."+ "Please check your internet connection or proxy settings and try again.") from erequest_logger.log_request_response(operation_id=operation_id,diff --git a/comfy_api_nodes/util/download_helpers.py b/comfy_api_nodes/util/download_helpers.pyindex edd739789..b22cbfc22 100644--- a/comfy_api_nodes/util/download_helpers.py+++ b/comfy_api_nodes/util/download_helpers.py@@ -97,7 +97,7 @@ async def download_url_to_bytesio(with contextlib.suppress(Exception):request_logger.log_request_response(operation_id=op_id, request_method="GET", request_url=url)- session = aiohttp.ClientSession(timeout=timeout_cfg)+ session = aiohttp.ClientSession(timeout=timeout_cfg, trust_env=True)stop_evt = asyncio.Event()async def _monitor():@@ -217,7 +217,7 @@ async def download_url_to_bytesio(diag = await diagnose_connectivity()if not diag["internet_accessible"]:raise LocalNetworkError(- "Unable to connect to the network. Please check your internet connection and try again."+ "Unable to connect to the network. Please check your internet connection or proxy settings and try again.") from eraise ApiServerError("The remote service appears unreachable at this time.") from efinally:diff --git a/comfy_api_nodes/util/upload_helpers.py b/comfy_api_nodes/util/upload_helpers.pyindex 22582409f..fc3a59520 100644--- a/comfy_api_nodes/util/upload_helpers.py+++ b/comfy_api_nodes/util/upload_helpers.py@@ -291,7 +291,7 @@ async def upload_file(request_data=f"[File data {len(data)} bytes]",)- sess = aiohttp.ClientSession(timeout=timeout)+ sess = aiohttp.ClientSession(timeout=timeout, trust_env=True)req = sess.put(upload_url, data=data, headers=headers, skip_auto_headers=skip_auto_headers)req_task = asyncio.create_task(req)@@ -368,7 +368,7 @@ async def upload_file(diag = await diagnose_connectivity()if not diag["internet_accessible"]:raise LocalNetworkError(- "Unable to connect to the network. Please check your internet connection and try again."+ "Unable to connect to the network. Please check your internet connection or proxy settings and try again.") from eraise ApiServerError("The API service appears unreachable at this time.") from efinally:diff --git a/tests-unit/comfy_api_nodes_test/comfy_cloud_test.py b/tests-unit/comfy_api_nodes_test/comfy_cloud_test.pyindex 78ab160ea..b5c5ee181 100644--- a/tests-unit/comfy_api_nodes_test/comfy_cloud_test.py+++ b/tests-unit/comfy_api_nodes_test/comfy_cloud_test.py@@ -632,7 +632,7 @@ def _stub_download_session(monkeypatch, responses):seen_allow_redirects = []class Session:- def __init__(self, timeout):+ def __init__(self, timeout, trust_env):passasync def get(self, url, headers, allow_redirects=True):