Skip to content

feat: improve HTTP robustness with httpx and retry logic#121

Open
jethac wants to merge 1 commit intoLaurieWired:mainfrom
jethac:pr/http-robustness
Open

feat: improve HTTP robustness with httpx and retry logic#121
jethac wants to merge 1 commit intoLaurieWired:mainfrom
jethac:pr/http-robustness

Conversation

@jethac
Copy link

@jethac jethac commented Jan 10, 2026

tl,dr

  • Replace requests with httpx for connection pooling and better timeout handling
  • Add tenacity for automatic retry with exponential backoff on transient failures
  • Add configurable thread pool for Java HTTP server (default: 4 threads)

Background

The current requests-based implementation creates a new TCP connection for every single API call and has no retry logic. This causes real problems:

Problem 1: Connection Churn

When an LLM is analyzing a binary, it makes dozens of rapid-fire calls (list_functions, decompile, get_xrefs, etc.). Each call opens a new connection, does one request, then tears it down. This adds latency and wastes resources.

Problem 2: No Fault Tolerance

If Ghidra is momentarily busy (e.g., still processing a large decompilation) or there's a brief network hiccup, the request fails immediately. The user sees Request failed: Connection refused and has to retry manually.

What This PR Fixes:

Before After
New TCP connection per request Connection pooling (reuses connections)
Single attempt, fail immediately 3 retries with exponential backoff
5s timeout for everything 30s default timeout

Practical Impact:

  • Faster response times for successive calls (connection reuse)
  • Graceful handling of transient failures (Ghidra briefly unresponsive, network blip)
  • More reliable when running long analysis sessions
    The retry only triggers on ConnectError and ConnectTimeout - actual API errors (4xx/5xx) still fail fast as expected.

Changes

  • Python bridge: httpx client with connection pooling, retry decorator for ConnectError/ConnectTimeout
  • Java plugin: ExecutorService thread pool instead of null executor, configurable via Tool Options
  • requirements.txt: Updated dependencies (httpx, tenacity)

Testing

  • Tested with multiple concurrent MCP requests
  • Verified retry behavior on connection failures

- Replace requests with httpx for better connection pooling
- Add tenacity for automatic retry on transient failures
- Retry up to 3 times with exponential backoff on ConnectError/ConnectTimeout
- Add connection-pooled HTTP client singleton
jethac added a commit to jethac/GhidraMCP that referenced this pull request Jan 11, 2026
- Add PORT_RANGE (8080-8089) for scanning active Ghidra instances
- Add discover_instances() to find running Ghidra servers
- Add get_instance_url() for routing requests to specific instances
- Add list_ghidra_instances() tool to list available instances
- Add target_binary parameter to all tools for instance routing

Depends-On: LaurieWired#121
jethac added a commit to jethac/GhidraMCP that referenced this pull request Jan 11, 2026
- Add PORT_RANGE (8080-8089) for scanning active Ghidra instances
- Add discover_instances() to find running Ghidra servers
- Add get_instance_url() for routing requests to specific instances
- Add list_ghidra_instances() tool to list available instances
- Add target_binary parameter to all tools for instance routing

Depends-On: LaurieWired#121
Copy link

@bethington bethington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! httpx with retry logic is a solid improvement for reliability.

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.

2 participants