fix: use host.docker.internal for Transmission RPC connection
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 3m34s
Run Tests / Backend Tests (push) Failing after 4m8s
Run Tests / Frontend Tests (push) Failing after 2m6s
Run Tests / Test Summary (push) Failing after 13s

This commit is contained in:
Gan, Jimmy
2026-04-11 13:20:10 +08:00
parent 6ea64bc19e
commit 6ad885044b
+10 -12
View File
@@ -10,17 +10,15 @@ router = APIRouter(prefix="/api/transmission", tags=["transmission"])
def get_session_id() -> str:
"""Get Transmission RPC session ID"""
try:
result = subprocess.run(
["ssh", "nas", "curl -si -u 'admin:admin' 'http://127.0.0.1:9091/transmission/rpc' 2>&1 | grep -i 'X-Transmission-Session-Id:' | cut -d' ' -f2 | tr -d '\\r'"],
capture_output=True,
text=True,
shell=True,
timeout=5
)
session_id = result.stdout.strip()
if not session_id:
raise Exception("Failed to get session ID")
return session_id
with httpx.Client(timeout=5.0) as client:
response = client.get(
"http://host.docker.internal:9091/transmission/rpc",
auth=("admin", "admin")
)
session_id = response.headers.get("X-Transmission-Session-Id")
if not session_id:
raise Exception("Failed to get session ID from headers")
return session_id
except Exception as e:
raise HTTPException(status_code=500, detail=f"Failed to get Transmission session ID: {str(e)}")
@@ -37,7 +35,7 @@ def transmission_rpc(method: str, arguments: Dict[str, Any] = None) -> Dict[str,
# Use httpx to make the request
with httpx.Client(timeout=10.0) as client:
response = client.post(
"http://100.78.131.124:9091/transmission/rpc",
"http://host.docker.internal:9091/transmission/rpc",
json=payload,
auth=("admin", "admin"),
headers={"X-Transmission-Session-Id": session_id}