EFOError when trying to connect Pyftpsync to remote server on port 22

Question:

I am trying to sync two folders via FTP, yes I know there are better or different ways but for now I need to implement it this way, I was trying the example code from pyftpsync since well, a sample code should work easily right? I am just trying to connect between some test folders I made, one is empty(local) and the remote has a single text file that I want to fetch. It tries to connect but after about 2 minutes I get this error.

Well, my FTP does work outside of python. I can connect over WinSCP just fine.

Some places mentioned that a proxy could possibly cause this, but it seems I am not behind a proxy currently, but maybe I did not set that properly and it believes there should be a proxy somehow?

Here is my code, just using commands on the prompt for pyftpsync produces the same errors for me. So it is possible some input parameter is off causing all of this.

import time
import os
import re
import shutil
import string
import sys

from ftpsync.targets import FsTarget
from ftpsync.ftp_target import FtpTarget 
from ftpsync.synchronizers import DownloadSynchronizer

#synchronize a local folder with ftp

local = FsTarget( "C:\testfolder\"  ) 
user = "login"
passwd = "password"
remote = FtpTarget("/my/folder/location/testfold/", "126.0.0.1",port=22, username=user,password=passwd,tls=False,timeout=None,extra_opts=None)
opts = {}
s=DownloadSynchronizer(local, remote, opts)
s.run()

This is the output I am getting, I have edited out the folder names and IP addresses.

INFO:keyring.backend:Loading KWallet
INFO:keyring.backend:Loading SecretService
INFO:keyring.backend:Loading Windows
INFO:keyring.backend:Loading chainer
INFO:keyring.backend:Loading macOS
INFO:pyftpsync:Download to C:testfolder
                from ftp://126.0.0.1/.../testfold
INFO:pyftpsync:Encoding local: utf-8, remote: utf-8
Traceback (most recent call last):
  File "c:...py", line 30, in <module>
    s.run()
  File "C:\AppDataLocalProgramsPythonPython37-32libsite- 
packagesftpsyncsynchronizers.py", line 1268, in run
  res = super(DownloadSynchronizer, self).run()
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libsite-packagesftpsyncsynchronizers.py", line 827, in run
  res = super(BiDirSynchronizer, self).run()
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libsite-packagesftpsyncsynchronizers.py", line 211, in run
  self.remote.open()
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libsite-packagesftpsyncftp_target.py", line 141, in open
  self.ftp.connect(self.host, self.port)
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libftplib.py", line 155, in connect
  self.welcome = self.getresp()
  File "C:\LocalProgramsPythonPython37- 
  32libftplib.py", line 236, in getresp
  resp = self.getmultiline()
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libftplib.py", line 226, in getmultiline
  nextline = self.getline()
  File "C:\AppDataLocalProgramsPythonPython37- 
  32libftplib.py", line 210, in getline
  raise EOFError
  EOFError

Anyways any possible troubleshooting ideas would help. Thank you.

Asked By: Juan

||

Answers:

Pyftpsync uses FTP protocol.

You are connecting to port 22, which is used for SSH/SFTP.

So if your server is actually SFTP server, not FTP server, you cannot use Pyftpsync with it.

Answered By: Martin Prikryl
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.