Skip to content

Commit 047a9ea

Browse files
author
maebahesioru
committed
fix: use port 19222 for Camoufox to avoid Windows reserved range, downgrade proxy errors to WARNING
1 parent b495e9d commit 047a9ea

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/api/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ async def lifespan(app: FastAPI):
182182
except Exception as e:
183183
if 'Target page, context or browser has been closed' in str(e):
184184
logger.warning(f'Application startup failed (browser closed): {e}')
185+
elif 'NS_ERROR_PROXY' in str(e) or 'PROXY_CONNECTION_REFUSED' in str(e):
186+
logger.warning(f'Application startup failed (proxy error): {e}')
185187
else:
186188
logger.critical(f'Application startup failed: {e}', exc_info=True)
187189
await _shutdown_resources()

src/browser/initialization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ async def _initialize_page_logic(browser: AsyncBrowser):
348348
raise RuntimeError(f'页面初始化失败:核心输入区域未在预期时间内变为可见。最后的 URL 是 {found_page.url}') from input_visible_err
349349
except Exception as e_init_page:
350350
is_browser_closed = 'Target page, context or browser has been closed' in str(e_init_page)
351+
is_proxy_error = 'NS_ERROR_PROXY' in str(e_init_page) or 'PROXY_CONNECTION_REFUSED' in str(e_init_page)
351352
if is_browser_closed:
352353
logger.warning(f'页面初始化时浏览器已关闭: {e_init_page}')
354+
elif is_proxy_error:
355+
logger.warning(f'页面初始化时代理连接失败: {e_init_page}')
353356
else:
354357
logger.critical(f'❌ 页面逻辑初始化期间发生严重意外错误: {e_init_page}', exc_info=True)
355358
if temp_context:

src/launch_camoufox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
PYTHON_EXECUTABLE = sys.executable
3535
ENDPOINT_CAPTURE_TIMEOUT = int(os.environ.get('ENDPOINT_CAPTURE_TIMEOUT', '90'))
3636
DEFAULT_SERVER_PORT = int(os.environ.get('DEFAULT_FASTAPI_PORT', '2048'))
37-
DEFAULT_CAMOUFOX_PORT = int(os.environ.get('DEFAULT_CAMOUFOX_PORT', '9222'))
37+
DEFAULT_CAMOUFOX_PORT = int(os.environ.get('DEFAULT_CAMOUFOX_PORT', '19222'))
3838
DEFAULT_STREAM_PORT = int(os.environ.get('STREAM_PORT', '3120'))
3939
DEFAULT_HELPER_ENDPOINT = os.environ.get('GUI_DEFAULT_HELPER_ENDPOINT', '')
4040
DEFAULT_AUTH_SAVE_TIMEOUT = int(os.environ.get('AUTH_SAVE_TIMEOUT', '30'))

0 commit comments

Comments
 (0)