Spaces:
Running
Running
Commit ·
5b492d5
1
Parent(s): 861735d
debug: /api/sftp-test returns JSON on connect failure
Browse files- backend/api.py +4 -1
backend/api.py
CHANGED
|
@@ -241,7 +241,10 @@ def api_sftp_test():
|
|
| 241 |
|
| 242 |
t0 = time.time()
|
| 243 |
# HARD socket timeout
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
| 245 |
t_sock = time.time()
|
| 246 |
|
| 247 |
tr = paramiko.Transport(sock)
|
|
|
|
| 241 |
|
| 242 |
t0 = time.time()
|
| 243 |
# HARD socket timeout
|
| 244 |
+
try:
|
| 245 |
+
sock = socket.create_connection((host, port), timeout=timeout)
|
| 246 |
+
except Exception as e:
|
| 247 |
+
return JSONResponse({"ok": False, "stage": "connect", "error": str(e), "host": host, "port": port, "timeout": timeout}, status_code=502)
|
| 248 |
t_sock = time.time()
|
| 249 |
|
| 250 |
tr = paramiko.Transport(sock)
|