0

Below is the code. ftps server on Azure and its Windows machine with FTPS filezilla server running. Requirement is to connect to ftps server and upload files. FTPS connection is not successful. c

import ftplib
from ftplib import FTP_TLS

ftpss = ftplib.FTP_TLS(host='11.22.333.44', user='xx', passwd='yyy',timeout=80) 
ftpss = login()
ftpss.ccc()
ftpss.prot_p()

Getting error

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Traceback (most recent call last):
  File "C:\Users\krst\scripts\Item_master_dump_to_ftp\epc_audit\test_ftps.py", line 69, in <module>
    ftpss = ftplib.FTP_TLS(host='11.22.333.44', user='abc', passwd='xzy',timeout=80)
  File "C:\Users\gyn\AppData\Local\Programs\Python\Python38-32\lib\ftplib.py", line 728, in __init__
    FTP.__init__(self, host, user, passwd, acct, timeout, source_address)
  File "C:\Users\gyn\AppData\Local\Programs\Python\Python38-32\lib\ftplib.py", line 117, in __init__
    self.connect(host)
  File "C:\Users\gyn\AppData\Local\Programs\Python\Python38-32\lib\ftplib.py", line 152, in connect
    self.sock = socket.create_connection((self.host, self.port), self.timeout,
  File "C:\Users\gyn\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 808, in create_connection
    raise err
  File "C:\Users\gyn\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 796, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

i'm able to telnet the ftps server ip and port(990). Able to connect the ftps server and see folders using winscp. using winscp tool the File protocol is chosen as "FTP" and encryption as "TLS/SSL Implicit encryption"

James Z
  • 12,209
  • 10
  • 24
  • 44
mb_pravi
  • 23
  • 6
  • FWIW, `FTP_TLS` uses port 21 by default (https://docs.python.org/3/library/ftplib.html#ftplib.FTP_TLS), but it does not seem to accept a `port` argument. So, I would try to provide `'11.22.333.44:990'` as `host`. – DeepSpace Apr 29 '20 at 16:07
  • If you create a `FTP_TLS` Object without giving it any options, you should be able to call `.connect` on it where you can specify the `port` argument. See the documentation for more info: https://docs.python.org/3/library/ftplib.html#ftplib.FTP.connect – Hampus Larsson Apr 29 '20 at 16:17
  • `11.22.333.44` is neither an hostname nor a valid IP address... – Patrick Mevzek Apr 29 '20 at 16:56
  • @PatrickMevzek , giving the valid host on code – mb_pravi Apr 29 '20 at 17:59
  • @HampusLarsson , i tried that also it didnt work – mb_pravi Apr 29 '20 at 18:00
  • 1
    990 is implicit FTPS port – See [Python FTP implicit TLS connection issue](https://stackoverflow.com/q/12164470/850848). – Martin Prikryl Apr 29 '20 at 18:46
  • I tried the code below: ```import ftplib ftps = ftplib.FTP_TLS('my host ip address') ftps.connect(port=990) ftps.auth() ftps.login(user="My username ", passwd="Mypassword") ftps.sendcmd("lmftpsuser") ftps.sendcmd("33dfj48XCM$")``` **got below error:** in ftps = ftplib.FTP_TLS('My host IP') in __init__FTP.__init__(self, host, user, passwd, acct, timeout, source_address) in connect self.sock = socket.create_connection((self.host, self.port), self.timeout socket.py", line 808, in create_connection raise err socket.py", line 796, in create_connection sock.connect(sa) – mb_pravi Apr 30 '20 at 06:59
  • @MartinPrikryl There was code to connect FTPS , a module to import on another python file. getting error in that too : **from ImplicityTLS import tyFTP ModuleNotFoundError: No module named 'ImplicityTLS'** – mb_pravi Apr 30 '20 at 17:13

0 Answers0