~sschwarzer/ftputil#97: 
Can't connect FTPHost with ftputil 3.2, Python 3.3.0 (win32)

I just installed your lib and tried to run your sample code:

with ftputil.FTPHost(FtpCred['host'],FtpCred['userid'],FtpCred['password']) as ftpHost:
        print(ftpHost.listdir(ftp_host.curdir))

Got the following error:

Traceback (most recent call last):
  File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 129, in _make_session
    return factory(*args, **kwargs)
  File "C:\Program Files\Python33\lib\ftplib.py", line 114, in __init__
    self.connect(host)
  File "C:\Program Files\Python33\lib\ftplib.py", line 148, in connect
    source_address=self.source_address)
  File "C:\Program Files\Python33\lib\socket.py", line 406, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 420, in run_nodebug
  File "C:\Users\npochez\Documents\GitHub\RunKS-1\SendFiles.py", line 21, in <module>
    with ftputil.FTPHost(FtpCred['host'],FtpCred['userid'],FtpCred['password']) as ftpHost:
  File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 69, in __init__
    self._session = self._make_session()
  File "C:\Program Files\Python33\lib\site-packages\ftputil\host.py", line 129, in _make_session
    return factory(*args, **kwargs)
  File "C:\Program Files\Python33\lib\site-packages\ftputil\error.py", line 146, in __exit__
    raise FTPOSError(*exc_value.args, original_exception=exc_value)
ftputil.error.FTPOSError: [Errno 11001] getaddrinfo failed
Debugging info: ftputil 3.2, Python 3.3.0 (win32)
Status
RESOLVED DUPLICATE
Submitter
ftputiluser (unverified)
Assigned to
No-one
Submitted
9 years ago
Updated
9 years ago
Labels
bug library

schwa (unverified) 9 years ago · edit

Thanks for the report!

If I remember correctly, I've seen this problem where someone had included an ftp:// prefix in the host address. Python's socket library, and thus ftputil, will only accept a mere host name without a URL protocol prefix.

Another possibility is that the nameserver you're using isn't reachable or doesn't work properly. Can you "ping" the FTP host from the command line (from the same machine where your ftputil client code runs)? Can you connect to the server with a command line FTP client?

If these hints don't help, please provide the value of FtpCred['host']. (For Python 3, this must be a unicode string (the built-in str type), not a byte string.)

If the hints do help, please let me know as well, so that I can close the ticket. :-)

schwa (unverified) 8 years ago · edit

Since I didn't get any feedback since my last comment and can't reproduce the problem, I close the ticket for now. Please reopen the ticket and provide further details if the problem is still present for you.

schwa (unverified) 8 years ago · edit

The error may also come from a name server problem.

By the way, there's a similar issue in ticket #76. The error number there is different, but this could be because of the different platforms. Ticket #76 was for Linux whereas this ticket is for Windows, as you can see in the last lines of the tracebacks.

schwa (unverified) 8 years ago · edit

In a Wine environment, I get

>>> socket.getaddrinfo("localhost:22", 22)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.gaierror: [Errno 11001] getaddrinfo failed

>>> socket.getaddrinfo("ftp://localhost", 22) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.gaierror: [Errno 11001] getaddrinfo failed

Therefore, I'll change the resolution to "duplicate".

schwa (unverified) 8 years ago · edit

Duplicate of ticket #76.

Register here or Log in to comment, or comment via email.