spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

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

Closed Anahid closed 8 years ago

Anahid commented 8 years ago

Hi,

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). 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.

Many Thanks.

Ana

popomore commented 8 years ago

Try to use path to find you file on Windows.

Anahid commented 8 years ago

Thank you so much for your response! can you please explain more?

Anahid commented 8 years ago

I have the directory on my windows node server machine. the file test.txt does exist on my linux remote server as well. Not sure what is wrong.

popomore commented 8 years ago

Maybe you can write like 'H:\\dataDirOnNodeServer'

Anahid commented 8 years ago

Thanks for your reply! tried this, it didn't work, sorry i forgot to mention what I have tried already, I have tried ./ , ./H:/dataDirOnNodeServer and ./H:/dataDirOnNodeServer/ also /H:/dataDirOnNodeServer, also tried uploading to the linux machine from windows node server, it works fine, it's only the download from linux to windows node server that does not work.

Anahid commented 8 years ago

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.