简体   繁体   中英

Error: Underlying stream not writable when trying to download file from remote server to node server

I am trying to download a file from a remote linux server (from directory /home/dataFiles/test.txt) into node server (to directory H:/dataDirOnNodeServer) using the node-scp2 module. In order to do so I run the following:

client.scp('linuxUsername:linuxPassword@linuxserverName:/home/dataFiles/test.txt', 'H:/dataDirOnNodeServer', function(err) {
     console.log(err);
})

I get an error: Error: Underlying stream not writable

I would really appreciate it if you can help me with this or if you can advise how to do it differently to make it work.

I solved this! The issue was that I was calling this client within a success of another client, therefore the file was using the same instance to perform the copy. To fix this I changed the scp library code loacted in scp2/lib/scp.js as follows:

-var client = require('./client');
+var Client = require('./client').Client;
+var client = new Client();

(First line was removed and the two lines below were added), this way every time a new instance is called. This also solved an issue of stack overflow I was getting prior this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM