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

TLSSocket.destroy() is not fully closing the socket #878

Closed
user447463 opened this issue Feb 18, 2015 · 3 comments
Closed

TLSSocket.destroy() is not fully closing the socket #878

user447463 opened this issue Feb 18, 2015 · 3 comments

Comments

@user447463
Copy link

io.js (along with node 0.12) seems to have introduced a timeout related issue for the TLS package. Closing the TLSSocket is not enough to stop the timeout but an additional TCP socket close is necessary.

Please see the following code sample for a reproducible pattern

var url=require('url').parse(process.argv[2]);
var secure=url.protocol=='https:';

var socket=new require('net').Socket();

socket.setTimeout(2000, function() {
    this.destroy();
    console.log('TCP connection timed out');
});

socket.connect({ host: url.hostname, port: url.port || (secure?443:80) }, function() {
    if (secure)
    {
        require('tls').connect({ socket: this, rejectUnauthorized: false, servername: url.hostname }, function() {
            this.destroy();
            console.log('SSL successfully connected');
        }).on('error', function(error){
            this.destroy();
            console.log('Error during SSL handshake');
        });
    }
    else
    {
        this.destroy();
        console.log('Non-SSL successfully connected');
    }
}).on('error', function(error) {
    this.destroy();
    console.log('Error during TCP connection '+error.code);
});

// Dummy line to keep node from exiting
setInterval(function() {}, 1000);

Expected result

iojs file.js https://www.google.com
SSL successfully connected

Actual result

iojs file.js https://www.google.com
SSL successfully connected
TCP connection timed out
@user447463
Copy link
Author

The issue is reproducible with all available io.js versions (1.x). As it was not present in node.js until version 0.11.3 (respectively 0.12 in release-terms) I presume io.js itself is based on a post-0.11.2 version, correct?

@user447463
Copy link
Author

For cross-reference, the respective bug at node.js
nodejs/node-v0.x-archive#9242

@user447463
Copy link
Author

Appears to have been fixed in node.js

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

1 participant