Avinashnalla7 commited on
Commit
5b492d5
·
1 Parent(s): 861735d

debug: /api/sftp-test returns JSON on connect failure

Browse files
Files changed (1) hide show
  1. 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
- sock = socket.create_connection((host, port), timeout=timeout)
 
 
 
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)