matlabftpconnection-refused

Why am I getting "connection-refused" when trying to access a TLS enabled FTP server [Box.com] via the Matlab ftp?


I'm trying to use the MATLAB FTP functionality to access files on my Box account. I usually deal with my box files manually via the Box web platform or through FileZilla, both without issue. However, I'm now trying to automate this process with Matlab and have seemingly fallen at the first hurdle.

Going by the MATLAB FTP documentation (link) I unsuccessfully tried to set up a ftp object for my Box address: (Note, I went through the example in that documentation without issue)

>>ftpobj = ftp("ftp.box.com",myUname, myPassword);

Error using matlab.io.ftp.FTP (line 175)
Connection refused for "ftp://ftp.box.com".

Error in ftp (line 63)
h = matlab.io.ftp.FTP(host, varargin{:});

Error in NotForGithub (line 8)
ftpobj = ftp("ftp.box.com",myUname, myPassword);

After some searching I found that r2021b had an FTP error at some point (link), but trying their example I found that wasn't the problem in my case:

>> ftpobj = ftp("ftp.ngdc.noaa.gov")

FTP with properties:
Host: "ftp.ngdc.noaa.gov"
Username: "anonymous"
Port: 21
ServerLocale: "en_US"
DirParserFcn: @matlab.io.ftp.parseDirListingForUnix
Mode: "binary"
LocalDataConnectionMethod: "passive"
RemoteWorkingDirectory: "/"

I updated Matlab anyway and the problem persists. Inspired by the above I tried to access Box without giving my details (in case there was a problem there specifically) and still got the following issue:

>> ftpobj = ftp("ftp.box.com")

Error using matlab.io.ftp.FTP (line 175)
Connection refused for "ftp://ftp.box.com".

Error in ftp (line 63)
h = matlab.io.ftp.FTP(host, varargin{:});

I've also seen people talk about the "SSH/SFTP/SCP for Matlab (v2)" (link), but it was not clear to me at all:
How would I apply that to what I'm trying to do?
Is that the solution?

(I also posted this on the MATLAB community forum and will stick any answers I get here as well (link))

This is the output when I connect via FileZilla:

Status: Resolving address of ftp.box.com
Status: Connecting to 107.152.26.220:21...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Status: Logged in
Status: Retrieving directory listing...
Status: Directory listing of "/" successful

Solution

  • You are using encrypted FTP over TLS in FileZilla. Doing the same in MATLAB seems to have fixed it:

    ftpobj = ftp("ftp.box.com", myUname, myPassword, 'TLSMode', 'strict');