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

How to end the connection? #5

Open
dkrebs opened this issue Feb 11, 2015 · 5 comments
Open

How to end the connection? #5

dkrebs opened this issue Feb 11, 2015 · 5 comments

Comments

@dkrebs
Copy link

dkrebs commented Feb 11, 2015

I'm trying to send a file via the client.put function to a server which I created with the tftp.createServer function. The server is set to allow put requests and saves the file in a directory. So far, everything is working, the file is present at the server and the size seems to be fine.

However, after sending the file, the client always get's a timeout [Error: Timed out] and I can't find any event which allows me to end the helper connection / see if the transfer was successful.

Any ideas? Thank you in advance! :)

Client:

        var client = tftp.createClient ({ port: PORT });
        client.put(local,function(error) {
            console.log('cb');
            if (error) console.error (error);
        });

Server:

        var server = tftp.createServer({
            host: HOST,
            port: PORT,
            root: rootDir,
            denyGET: true
        });

        server.on ("request", function (req, res){
            console.log(req.file);

            req.on ("error", function (error){
                console.error ("[" + req.stats.remoteAddress + ":" + req.stats.remotePort +
                    "] (" + req.file + ") " + error.message);
            });
            req.on('end',function(){
                console.log('req.close()');
                req.close();
            });
        });
        server.on('close',function(){
            console.log('closed'); 
        });
        server.on ("listening", function(){
            console.log('listening');
        });
        server.listen();
@TooTallNate
Copy link

👍

@somecallmemike
Copy link

I am having the same issue, I don't see a documented method for properly closing the connection. Can we get some clarification on this?

@somecallmemike
Copy link

Bueller?

@Monitor343
Copy link

I have been having this same issue with the server. The file gets uploaded in its entirety but the client never gets an OK. I did some packet captures and found that the server is not sending the ACK acknowledging the receipt of the final packet (a data packet smaller than set block size). The client then just re-transmits the last packet to the server until it times out and sends an error to the server.

Unfortunately, I have exhausted my Node.js skills and don't have any suggestions on how this can be fixed in the code.

@michau-krakow
Copy link

The problem is that client socket is being closed too soon after file transfer is finished. Socket is closed just after receiving last DATA packet, which means final ACK packet may not have enough time to get sent by the underlying OS functions, so the client may never receive the ACK.
As a result, the transfer is successfully finished on server but client would see failure, retransmissions and eventually a timeout.
A fix is provided in pull request #29

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

5 participants