gulp 4 Vinyl-ftp无法建立数据连接

时间:2018-09-14 08:50:57

标签: gulp vinyl-ftp

我在上传文件时遇到问题,随机会因各种错误而停止:无法在Socket上建立数据连接。 (/aaa/node_modules/ftp/lib/connection.js:935:10)错误:客户端异常终止。有时在启动时有效10次​​

var deployPaths =
{
    'aaa/public_html': [],
    'bbb/public_html': [],
};

var defaultTasks = [];

function deployMultiple(key) {

    var conn = ftp.create({
        host: 'site',
        user: 'xxxx',
        password: 'xxxxxx',
        parallel: 10,
        maxConnections: 5,
        log: plugins.util.log
    });

    var globs = [

        path + '/some_path/**',
        '!' + path + '/some_path/aa/**',
        '!' + path + '/some_path/bb/**',
        path + '/administrator/some_path/**',

    ];

    // using base = '.' will transfer everything to /public_html correctly
    // turn off buffering in gulp.src for best performance
    return gulp.src(globs, {base: path, buffer: false})
        .pipe(conn.newer(key)) // only upload newer files
        .pipe(conn.dest(key));


}

gulp.task('deploy-task', function (cb) {
    for (var key in deployPaths) {
        deployMultiple(key);
        cb();
    }

});

gulp.task('deploy',gulp.series('clean','git_export','deploy-task'));

请帮助,谢谢

1 个答案:

答案 0 :(得分:0)

@miojamo

我使用vinyl-ftpFileZilla为2个不同的托管服务提供商进行了测试,发现此错误仅发生在其中一个。查看更多here in vinyl-ftp Github repo issue

希望在这个问题上能有所启发。