Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put(), get() method does not work, but list() works. #45

Closed
chamsae opened this issue Mar 15, 2013 · 21 comments
Closed

put(), get() method does not work, but list() works. #45

chamsae opened this issue Mar 15, 2013 · 21 comments

Comments

@chamsae
Copy link

chamsae commented Mar 15, 2013

Hi,
I am trying to make FTP client by this module.
List() command works well.
but put(), get() as upload, download doesn't work.
I think I tried like your example.
I will show you my source.

In case of put(),

after greeting event, ready event,
I execute this code.

ftpWrok.ftpConnection.put('./ftp.txt', 'ftpcopy.txt', function(err){
        if(err){
            console.log(err);
        }else{
            console.log("====FTP file upload success?==");
        }
    });

ftp.txt is same directory with javascript source file.
but "ftpcopy.txt" created on FTPserver just include text "./ftp.txt".
it seems not to recognize first parameter input filename but just String.

In case of get(),

ftpWrok.ftpConnection.get('./ftpTest/ftp.txt', function(err, stream){
        if(err){
            console.log(err);
            throw err;
        }

        stream.once('close', function(){ftpWrok.ftpConnection.end();});
        stream.pipe(fs.createWriteStream('ftplocalcopy.txt'));
    });

emitted error.

console.logs are like below,

==============FTP greeting event===
=============FTP ready event===========
(execute download command)
===========FTP error event=========
{ [Error: OOPS: vsf_sysutil_recv_peek: no data] code: 500 }
===========FTP error event=========
{ [Error: OOPS: child died] code: 500 }
============FTP end event====
===========FTP close event====

if I have a mistake, could you comment some advice?

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

In put(),
now, I see relative path is server.js not javascript sourcefile included command code.
I changed path './routes/ftp.txt', then it uploaded successfully.
absolute path is not used '' but '/', it is my mistake!

but, In get(), not yet, I don't know why doesn't work.

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

For your get() issue, can you enable debugging by setting debug: console.log in the object passed to connect() and upload the resulting output?

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

Also, are you able to successfully transfer this same file on the same server with a different ftp client?

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

hi mscdex!, yes, in FileZilla FTP client works very well, upload and download both. same FTP server.
um.. how can I set debugging? is there an example about this?

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

@chamsae set debug: console.log in the object you are passing to connect() and post the resulting console output here.

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

I am sorry not to understand your meaning. I'm a newbie for english, nodejs.
I didn't understand what does put in "console.log( ? );"

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

Example:

ftp.connect({
  host: '127.0.0.1',
  user: 'foo',
  password: 'bar',
  debug: console.log // <-- add this line
});

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

OK! thank you for giving example!

Express server listening on port 3000
< '220 FTP Server ready .. \r\n'
Parsed response: code=220; buffer='FTP Server ready ..'
==============FTP greeting event===
> 'USER foo'
< '331 Password required for foo\r\n'
Parsed response: code=331; buffer='Password required for foo'
> 'PASS *******'
< '230-Allowed to connect server only in Korea.\r\n230 User foo logged in\r\n'
Parsed response: code=230; buffer='Allowed to connect server only in Korea.\r\nUser foo logged in'
> 'FEAT'
< '211-Features:\n MDTM\n REST STREAM\n SIZE\r\n211 End\r\n'
Parsed response: code=211; buffer='Features:\n MDTM\n REST STREAM\n SIZE\r\nEnd'
> 'TYPE I'
< '200 Type set to I\r\n'
Parsed response: code=200; buffer='Type set to I'
> 'PASV'
< '227 Entering Passive Mode (112,175,50,229,226,154).\r\n'
Parsed response: code=227; buffer='Entering Passive Mode (112,175,50,229,226,154).'
> 'SYST'
< '215 UNIX Type: L8\r\n'
Parsed response: code=215; buffer='UNIX Type: L8'
UNIX
> 'LIST'
< '150 Opening ASCII mode data connection for file list\r\n'
Parsed response: code=150; buffer='Opening ASCII mode data connection for file list'
< '226 Transfer complete\r\n'
Parsed response: code=226; buffer='Transfer complete'
=============FTP ready event===========
> 'PASV'
< '227 Entering Passive Mode (112,175,50,229,217,238).\r\n'
Parsed response: code=227; buffer='Entering Passive Mode (112,175,50,229,217,238).'
> 'RETR ./www/galleryImage/sdf222222s.txt'
< '550 ./www/galleryImage/sdf222222s.txt: No such file or directory\r\n'

C:\Users\HUMMING\Dropbox\vvvv13\NodeMail\routes\ftpWork.js:40
                throw err;
                      ^
Error: ./www/galleryImage/sdf222222s.txt: No such file or directory
    at makeError (C:\Users\HUMMING\Dropbox\vvvv13\NodeMail\node_modules\ftp\lib\ftp.js:1074:13)
    at Socket.ondata (C:\Users\HUMMING\Dropbox\vvvv13\NodeMail\node_modules\ftp\lib\ftp.js:263:27)
    at Socket.EventEmitter.emit (events.js:96:17)
    at TCP.onread (net.js:392:31)

Process finished with exit code 1

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

Ok, that's a different error. Can you provide the output that generates the 'vsf_sysutil_recv_peek: no data' error?

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

path is like below.

ftpTree

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

What if you try using '/www/galleryImage/sdf222222s.txt', without the '.' in front? Or change to the 'www' directory, then to the 'galleryImage' directory, and then try get()'ing 'sdf222222s.txt'?

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

Ok. I'll try that.

and I don't know why.. no more occur first error "[Error: OOPS: vsf_sysutil_recv_peek: no data] code: 500".
now, it just occurs "Error: ./www/galleryImage/sdf222222s.txt: No such file or directory".
it maybe just path error.

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

WOW suceess download. thank you very much, mscdex!!!
it just because '.' in front!

Express server listening on port 3000
< '220 FTP Server ready .. \r\n'
Parsed response: code=220; buffer='FTP Server ready ..'
==============FTP greeting event 서버가 뭔가 보내고 난 다음에 뜨는 거래===
> 'USER foo'
< '331 Password required for foo\r\n'
Parsed response: code=331; buffer='Password required for foo'
> 'PASS ******'
< '230-Allowed to connect server only in Korea.\r\n230 User foo logged in\r\n'
Parsed response: code=230; buffer='Allowed to connect server only in Korea.\r\nUser foo logged in'
> 'FEAT'
< '211-Features:\n MDTM\n REST STREAM\n SIZE\r\n211 End\r\n'
Parsed response: code=211; buffer='Features:\n MDTM\n REST STREAM\n SIZE\r\nEnd'
> 'TYPE I'
< '200 Type set to I\r\n'
Parsed response: code=200; buffer='Type set to I'
> 'PASV'
< '227 Entering Passive Mode (112,175,50,229,212,233).\r\n'
Parsed response: code=227; buffer='Entering Passive Mode (112,175,50,229,212,233).'
> 'SYST'
< '215 UNIX Type: L8\r\n'
Parsed response: code=215; buffer='UNIX Type: L8'
UNIX
> 'LIST'
< '150 Opening ASCII mode data connection for file list\r\n'
Parsed response: code=150; buffer='Opening ASCII mode data connection for file list'
< '226 Transfer complete\r\n'
Parsed response: code=226; buffer='Transfer complete'
=============FTP ready event===========
> 'PASV'
< '227 Entering Passive Mode (112,175,50,229,158,198).\r\n'
Parsed response: code=227; buffer='Entering Passive Mode (112,175,50,229,158,198).'
> 'RETR /www/galleryImage/bloom_two_iphone.jpg'
< '150 Opening BINARY mode data connection for /www/galleryImage/bloom_two_iphone.jpg (191812 bytes)\r\n'
Parsed response: code=150; buffer='Opening BINARY mode data connection for /www/galleryImage/bloom_two_iphone.jpg (191812 bytes)'
< '226 Transfer complete\r\n'
Parsed response: code=226; buffer='Transfer complete'
> 'MODE S'
< '200 Mode set to S\r\n'
Parsed response: code=200; buffer='Mode set to S'

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

and I have another problem just now about connection, could you answer more?

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

sure, go ahead

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

You looks very kind, thank you.
I start,

I want to keep FTP connection for forever until I shutdown Express Server though not transferring file or listing.
but default setting seems to disconnect after 900 second, and emit error.
where can I edit code?

===========FTP error event=========
{ [Error: No transfer timeout (900 seconds): closing control connection] code: 421 }
============FTP end event====
===========FTP close event====

events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: watch ECONNRESET
at errnoException (fs.js:806:11)
at FSEvent._handle.onchange (fs.js:824:26)

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

or I think,
It would be fine, it reconnect when need to transfer.
In normal case of FTP Client Program like FileZilla, it seems do that.

anyway, I tried reconnect after disconnect(maybe.. 'close event').
is it a right way?

c.on('close', function(hadErr){
console.log("===========FTP close event====");

c.connect({
    host : localhost,
    port : 21,
    user : 'myname',
    password : 'mypass',
    debug : console.log
});

});

simply, I want to fix the error "Error: No transfer timeout (900 seconds): closing control connection] code: 421",
and automatically reconnect when need transferring file.
could you comment me how can I do?

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

Ok, the keepalive mechanism should be fixed in c7aecf3. Give it a try with npm install https://github.com/mscdex/node-ftp/tarball/master. By default it will perform a NOOP every 10 seconds.

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

it maybe works!

NOOP
< '200 NOOP command successful\r\n'
Parsed response: code=200; buffer='NOOP command successful'

then, after setting like this, never close connection?
this is what I want, but I don't know whether this is good way.
FileZilla FTP Client seems to reconnect if need transferring, after quickly closing.
how do you think about this?

c.connect({
host : localhost,
port : 21,
user : 'myname',
password : 'mypass',
debug : console.log
keepalive : 30000
});

@mscdex
Copy link
Owner

mscdex commented Mar 15, 2013

You could probably do both: rely on keepalive and reconnect if disconnected. It's difficult to say if any given server will kill a connection if it sees the client is just continually sending NOOPs. I would hope most would not though and would keep the connection open.

@chamsae
Copy link
Author

chamsae commented Mar 15, 2013

Ok, thank you mscdex.
I don't know whether have bothering you today many time.
you are good programmer. see you later.

@chamsae chamsae closed this as completed Mar 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants