node.js(或nwjs)ftp下载

node.js (or nwjs) ftp download

需要定期从 public ftp 下载新文件: ftp://ftp.cmegroup.com/bulletin/

但是我无法连接 ftp 模块来切断。我的代码是:

var url = "ftp://ftp.cmegroup.com/bulletin/";
var path = require('path');
var fs = require('fs');
//var Promise = require('bluebird');
var Client = require('ftp');

var c = new Client();

var connectionProperties = {
    host: "ftp.cmegroup.com",
};

c.on('ready', function () {
    console.log('ready');
    c.list(function (err, list) {
        if (err) throw err;
        list.forEach(function (element, index, array) {
            //Ignore directories
            if (element.type === 'd') {
                console.log('ignoring directory ' + element.name);
                return;
            }
            //Ignore non zips
            if (path.extname(element.name) !== '.zip') {
                console.log('ignoring file ' + element.name);
                return;
            }
            //Download files
            c.get(element.name, function (err, stream) {
                if (err) throw err;
                stream.once('close', function () {
                    c.end();
                });
                stream.pipe(fs.createWriteStream(element.name));
            });
        });
    });
});


c.connect(connectionProperties); 

错误:

Uncaught Error: connect ECONNREFUSED 127.0.0.1:21

不明白为什么它连接到本地主机,尽管我指出了连接参数。

缺一行

c.connect(connectionProperties);