Skip to content

Instantly share code, notes, and snippets.

View odysseus0's full-sized avatar
🎯
Focusing

George Zhang odysseus0

🎯
Focusing
View GitHub Profile
@odysseus0
odysseus0 / gist_compare_sync_async.py
Created June 20, 2025 09:51
Compare sync vs async httpx - Phase 1 investigation
#!/usr/bin/env python3
import asyncio
import httpx
import threading
import concurrent.futures
def sync_test():
"""Test with synchronous httpx client."""
print("🔄 Testing synchronous httpx.Client...")
@odysseus0
odysseus0 / gist_ipv6_pattern_test.py
Created June 20, 2025 09:51
IPv6 Pattern Test - The script that revealed the hotel WiFi issue
#!/usr/bin/env python3
"""
IPv6 Pattern Test - The script that revealed the hotel WiFi issue
This is the actual script Claude Code wrote that tested multiple services
and revealed the pattern: all real IPv6 addresses failed at TLS,
while IPv6-mapped IPv4 addresses worked fine.
When run at home, everything worked - revealing it was the hotel WiFi
breaking IPv6 in a very specific way.
@odysseus0
odysseus0 / gist_happy_eyeballs_test_actual.py
Created June 20, 2025 09:50
Happy Eyeballs Test - Verify httpx 0.28+ behavior with IPv6
#!/usr/bin/env python3
"""
Happy Eyeballs Test - Verify if Happy Eyeballs in httpx 0.28+ resolves IPv6 issues.
This tests whether we still need the manual IPv4 forcing.
Spoiler: Happy Eyeballs exists but can't help when TCP succeeds but TLS fails.
"""
import asyncio
import httpx
@odysseus0
odysseus0 / gist_http_client_detective_actual.py
Created June 20, 2025 09:50
HTTP Client Detective - Test all Python HTTP clients
#!/usr/bin/env python3
# /// script
# dependencies = [
# "httpx",
# "aiohttp",
# "requests",
# ]
# requires-python = ">=3.8"
# ///
@odysseus0
odysseus0 / The Empty HTTPX Error String That Cost Me 3 Hours.md
Created June 20, 2025 02:00
The Empty HTTPX Error String That Cost Me 3 Hours (Spoiler: It Was DNS) - A debugging journey through Python's network stack

The Empty HTTPX Error String That Cost Me 3 Hours (Spoiler: It Was DNS)

Or: How I Learned to Stop Worrying and Blame DNS

TL;DR: httpx AsyncClient was failing with empty error messages while every other HTTP client worked. After 3 hours debugging through Python's entire network stack, I discovered it was trying IPv6 (TikAPI's DNS returns IPv6 but refuses IPv6 connections). The fix? One line: httpx.AsyncHTTPTransport(local_address="0.0.0.0"). Yes, it was DNS.

It started with the most frustrating error message I've ever seen:

{"detail":"An error occurred while requesting TikAPI: "}
@odysseus0
odysseus0 / gist_dns_environment_scanner.py
Last active June 20, 2025 00:32
DNS Environment Scanner - Diagnose 'works on my machine' networking issues by comparing DNS and connectivity
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.7"
# ///
"""
DNS Environment Scanner - Diagnose "Works on My Machine" Issues
https://gist.github.com/odysseus0/bd9c3e0cf7f0b2e1222b609577fc4eb1
This tool revealed why httpx AsyncClient worked on my colleague's machine
@odysseus0
odysseus0 / gist_socket_spy.py
Last active June 20, 2025 00:32
Socket Spy - Monitor all socket operations in Python to debug networking issues at the lowest level
#!/usr/bin/env python3
# /// script
# dependencies = [
# "httpx", # For the demo mode
# ]
# requires-python = ">=3.7"
# ///
"""
Socket Spy - Monitor all socket operations in Python
@odysseus0
odysseus0 / gist_http_client_detective.py
Last active June 20, 2025 00:32
HTTP Client Detective - Systematically test Python HTTP clients to find which ones work with your API
#!/usr/bin/env python3
# /// script
# dependencies = [
# "httpx",
# "aiohttp",
# "requests",
# ]
# requires-python = ">=3.7"
# ///
@odysseus0
odysseus0 / INVESTIGATION_MEMO.md
Created June 19, 2025 20:16
Investigation Memo: TikAPI httpx AsyncClient Issue

Investigation Memo: TikAPI httpx AsyncClient Issue

Date: June 19, 2025
Platform: MacOS
Project: TikAPI_MCP
Environment: /Users/tengjizhang/projects/flashbots_x/TikAPI_MCP

Problem Statement

The TikAPI MCP server was experiencing failures when making requests to the TikAPI service, with empty error messages: "An error occurred while requesting TikAPI: ". This prevented the /resources/read and search functionality from working properly.

package main
import "fmt"
func main() {
hello()
}
func hello() {
fmt.Println("Hello, World!")