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

0.12.7 vs 4.1.1 - Are there some changes in net.Socket? #3056

Closed
o5 opened this issue Sep 24, 2015 · 14 comments
Closed

0.12.7 vs 4.1.1 - Are there some changes in net.Socket? #3056

o5 opened this issue Sep 24, 2015 · 14 comments
Assignees
Labels
net Issues and PRs related to the net subsystem. question Issues that look for answers.

Comments

@o5
Copy link

o5 commented Sep 24, 2015

Hi,

I created a small micro-service called "Port Checker Tool", but today, I tried to upgrade from v0.12.7 to v4.1.1 but service doesn't work for now.

I prepared a small code for reproduction. It does nothing special, it creates a HTTP server, listen on port 8000 and when you open http://localhost:8000/start in your browser, it will create a sync queue with ports for checking connection (is connection on some port is open or not). I'm using a last version of async library "async": "~1.4.2".

index.js

var Http = require('http'),
    Net  = require('net'),
    Async = require('async');

var server = Http.createServer(function(request, response) {
    if (request.url === '/start') {
        var queue = Async.queue(function(port, done) {

            console.time('PORT:' + port);

            var socket = new Net.Socket();
            socket.setTimeout(1000);

            socket.connect(port, '173.194.122.7', function () {
                console.timeEnd('PORT:' + port);
                console.log('OPEN\n');
                socket.destroy();
                done();
            });

            socket.on('error', function (e) {
                console.timeEnd('PORT:' + port);
                console.log('ERROR:', e, '\n');
                socket.destroy();
                done();
            });

            socket.on('timeout', function () {
                console.timeEnd('PORT:' + port);
                console.log('CLOSED\n');
                socket.destroy();
                done();
            });
        }, 1);

        queue.push([70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90]);
        queue.drain = function() {
            console.log('THE END!');
        };
    }

    response.end('OK');
});

server.listen(8000);

There are two differences when node is 4.1.1

  1. some timeouts aren't ~1000ms
  2. some check ends with error

There is an output from terminal, when I use an old version of Node.

[~/]$ node -v
v0.12.7

[~/]$ node index.js
PORT:70: 1009ms
CLOSED

PORT:72: 1002ms
CLOSED

PORT:74: 1004ms
CLOSED

PORT:76: 1003ms
CLOSED

PORT:78: 1005ms
CLOSED

PORT:80: 15ms
OPEN

PORT:82: 1003ms
CLOSED

PORT:84: 1004ms
CLOSED

PORT:86: 1003ms
CLOSED

PORT:88: 1004ms
CLOSED

PORT:90: 1004ms
CLOSED

THE END!

and there for new Node.js.

[~/]$ node -v
v4.1.1

[~/]$ node index.js
PORT:70: 1007ms
CLOSED

PORT:72: 75187ms
ERROR: { [Error: connect ETIMEDOUT 173.194.122.7:72]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '173.194.122.7',
  port: 72 }

PORT:74: 1002ms
CLOSED

PORT:76: 43151ms
CLOSED

PORT:78: 1003ms
CLOSED

PORT:80: 61ms
OPEN

PORT:82: 1005ms
CLOSED

PORT:84: 1004ms
CLOSED

PORT:86: 1003ms
CLOSED

PORT:88: 1003ms
CLOSED

PORT:90: 1006ms
CLOSED

THE END!

Maybe, I have something wrong with my code which work only with old version of node.

OSX 10.10.5

Thank you!

@o5 o5 changed the title Node.js v0.12.7 vs Node.js v4.1.1 - Are there some changes in net.Socket class? 0.12.7 vs 4.1.1 - Are there some changes in net.Socket class? Sep 24, 2015
@o5 o5 changed the title 0.12.7 vs 4.1.1 - Are there some changes in net.Socket class? 0.12.7 vs 4.1.1 - Are there some changes in net.Socket? Sep 24, 2015
@mscdex mscdex added question Issues that look for answers. net Issues and PRs related to the net subsystem. labels Sep 25, 2015
@brendanashworth
Copy link
Contributor

I don't believe any major changes have landed in the net module since io.js's first release. Is the test case reliable? Perhaps you'd like to git bisect over the code base?

@o5
Copy link
Author

o5 commented Sep 25, 2015

@brendanashworth I don't understand, what should I do more now. I added the minimal code for reproduction, did you try it? Did you same results?

@brendanashworth
Copy link
Contributor

@o5 after changing the IP to 127.0.0.1, I only get ECONNREFUSED for all (including :80), regardless of node version.

@o5
Copy link
Author

o5 commented Sep 25, 2015

@brendanashworth that is possible, but I don't want to scan local network.

@o5
Copy link
Author

o5 commented Sep 25, 2015

Its interesting, when you remove the "server wrapper", it works fine.

@mscdex
Copy link
Contributor

mscdex commented Sep 25, 2015

It's also better to have a reproducible example that excludes any/all third party modules.

@Fishrock123
Copy link
Contributor

Please see https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#net

It's possible that there were more changes than that, but I did an awful lot of digging and didn't find anything else.

@rvagg
Copy link
Member

rvagg commented Sep 29, 2015

libuv is likely where changes have occurred that impact on this, perhaps have a scan through the libuv changelog to see if anything stands out

@o5 o5 closed this as completed Sep 29, 2015
@o5 o5 reopened this Sep 29, 2015
@Fishrock123 Fishrock123 self-assigned this Oct 6, 2015
@Fishrock123
Copy link
Contributor

@rvagg hmmm, ok, I'll have a look this week if I get the chance.

@o5
Copy link
Author

o5 commented Oct 9, 2015

Same for v4.1.2 :-/

@Fishrock123
Copy link
Contributor

Yes, until you hear here nothing will have changed. :)

On Oct 9, 2015, at 1:10 PM, Petr Bugyík notifications@github.com wrote:

Same for v4.1.2 :-/


Reply to this email directly or view it on GitHub.

@o5
Copy link
Author

o5 commented Oct 30, 2015

Can anyone confirm this bug?

@evanlucas
Copy link
Contributor

Can you try running this with the latest stable? The latest stable version is v5.5.0. I am not able to reproduce the issue on it. Thanks!

@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

Closing for lack of any updates. Can reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

7 participants