SSH2.SFTP node.js备份脚本与大文件冻结

我试图创build一个脚本来传输文件到我的NAS用于备份的目的。 我正在使用SSH2模块( https://github.com/mscdex/ssh2 )来build立一个SFTP连接。 对于较小的文件一切顺利,大文件(> 500MB)通常会冻结70%到100%之间的完成。 fastPut方法,我用于转移,突然停止转移,不会触发任何事件了。

我已经拿出了相关的一段代码:

var uploadUpdate=true; sftp.fastPut(localPath+'/'+upload, receiver.path+'/'+newDir+'/'+upload, {step:function(totalTransferred, chunk, total){ if(uploadUpdate){ //since this event will be triggered a lot I figured I should keep some time (5 sec) between the logs uploadUpdate=false; console.log("- Progress '"+upload+"' => "+(Math.floor(totalTransferred/total*10000)/100)+"%, "+totalTransferred+" of "+total+" bytes, chunk: "+chunk); setTimeout(function(){ uploadUpdate=true; },5000); } }}, function(err){ if(err){ if(!fileErrors[upload]) fileErrors[upload]=0; ++fileErrors[upload]; if(fileErrors[upload]==5) console.log("'"+upload+"' failed 5 times... skipping now..."); else{ console.log("Upload of '"+upload+"' failed, re-add to queue."); uploadsToDo.push(upload); } } nextUpload(); }); 

有没有人有任何想法可能会导致这个问题?

我已经结束了文件分割成小块和发送,然后每当一段特定的时间没有进展我重新启动连接,并开始转移之前死亡。

不是很漂亮,但它完成了工作