Skip to content

Update connection.py#59

Open
MaikiOS wants to merge 1 commit intovinavfx:mainfrom
MaikiOS:patch-1
Open

Update connection.py#59
MaikiOS wants to merge 1 commit intovinavfx:mainfrom
MaikiOS:patch-1

Conversation

@MaikiOS
Copy link
Copy Markdown

@MaikiOS MaikiOS commented Aug 2, 2025

Fix: Proxy Handler Issue Causing 502 Bad Gateway Error Problem
Users experiencing "HTTP Error 502: Bad Gateway" when connecting Nuke to ComfyUI server, even though ComfyUI is running correctly and accessible via browser. Root Cause
The issue occurs when Nuke has system proxy settings configured (e.g., http://127.0.0.1:2080). The urllib2.urlopen() function automatically uses these proxy settings for all HTTP requests, including localhost connections. This causes the proxy server to attempt connecting to the ComfyUI server, resulting in a 502 Bad Gateway error. Solution
Modified connection.py to bypass proxy settings for localhost connections by implementing ProxyHandler({}) for all HTTP requests. Changes Made
Before:
pythonresponse = urllib2.urlopen(request, timeout=30) After:
python# Bypass proxy for localhost connections
no_proxy_handler = urllib2.ProxyHandler({})
opener = urllib2.build_opener(no_proxy_handler)
response = opener.open(request, timeout=30)
Functions Updated

GET() - for object_info and other API calls
check_connection() - for connection verification
POST() - for sending prompts and data

Testing
This fix was verified by testing direct urllib2 requests in Nuke Script Editor:

With proxy: HTTP Error 502: Bad Gateway
Without proxy: SUCCESS! Code: 200, Data length: 3,188,462

Compatibility
This change maintains backward compatibility and doesn't affect users without proxy settings, while fixing the connection issue for users with system proxies configured.

Fix: Proxy Handler Issue Causing 502 Bad Gateway Error
Problem
Users experiencing "HTTP Error 502: Bad Gateway" when connecting Nuke to ComfyUI server, even though ComfyUI is running correctly and accessible via browser.
Root Cause
The issue occurs when Nuke has system proxy settings configured (e.g., http://127.0.0.1:2080). The urllib2.urlopen() function automatically uses these proxy settings for all HTTP requests, including localhost connections. This causes the proxy server to attempt connecting to the ComfyUI server, resulting in a 502 Bad Gateway error.
Solution
Modified connection.py to bypass proxy settings for localhost connections by implementing ProxyHandler({}) for all HTTP requests.
Changes Made
Before:
pythonresponse = urllib2.urlopen(request, timeout=30)
After:
python# Bypass proxy for localhost connections
no_proxy_handler = urllib2.ProxyHandler({})
opener = urllib2.build_opener(no_proxy_handler)
response = opener.open(request, timeout=30)
Functions Updated

GET() - for object_info and other API calls
check_connection() - for connection verification
POST() - for sending prompts and data

Testing
This fix was verified by testing direct urllib2 requests in Nuke Script Editor:

With proxy: HTTP Error 502: Bad Gateway
Without proxy: SUCCESS! Code: 200, Data length: 3,188,462

Compatibility
This change maintains backward compatibility and doesn't affect users without proxy settings, while fixing the connection issue for users with system proxies configured.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant