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

Too many sockets of Ubuntu with 'CLOSE_WAIT' #9513

Closed
mike442144 opened this issue Nov 8, 2016 · 3 comments
Closed

Too many sockets of Ubuntu with 'CLOSE_WAIT' #9513

mike442144 opened this issue Nov 8, 2016 · 3 comments
Labels
http Issues or PRs related to the http subsystem. question Issues that look for answers.

Comments

@mike442144
Copy link

mike442144 commented Nov 8, 2016

  • Version:6.9.1
  • Platform:Ubuntu 16.04, Ubuntu 14.04
  • Subsystem:?

This is a problem found inrequest, in which I also post an issue, but after a few days tracking, we found that it is not an issue with request module itself, but _http_client.js or net.js, even tcp_wrap.cc. What is strange is the proxy server sent a FIN packet to me after a Connect response, and I cannot receive end event, but when there is an error on ClientRequest, I can receive a end event as expected.

Please see the code in _http_client.js:
in socketOnData funciton, the condition path related to Connect behavior. if there is listener of Connect or Upgrade, just emit, else destroy.

else if (parser.incoming && parser.incoming.upgrade) {
    // Upgrade or CONNECT
    var bytesParsed = ret;
    var res = parser.incoming;
    req.res = res;

    socket.removeListener('data', socketOnData);
    socket.removeListener('end', socketOnEnd);
    parser.finish();

    var bodyHead = d.slice(bytesParsed, d.length);

    var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
    if (req.listenerCount(eventName) > 0) {
      req.upgradeOrConnect = true;

      // detach the socket
      socket.emit('agentRemove');
      socket.removeListener('close', socketCloseListener);
      socket.removeListener('error', socketErrorListener);

      // TODO(isaacs): Need a way to reset a stream to fresh state
      // IE, not flowing, and not explicitly paused.
      socket._readableState.flowing = null;

      req.emit(eventName, res, socket, bodyHead);
      req.emit('close');
    } else {
      // Got Upgrade header or CONNECT method, but have no handler.
      socket.destroy();
    }
    freeParser(parser, req, socket);

As I said above, in my script, I got Connect event correctly, but the server sent FIN packet to me after that, and I cannot get end event, why? follow is the document of net_event_end, Anybody can help?

Thanks very much.

@Fishrock123 Fishrock123 added the question Issues that look for answers. label Nov 8, 2016
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Nov 8, 2016
@mike442144
Copy link
Author

Could anybody give me a hand?

@bnoordhuis
Copy link
Member

Can you post steps to reproduce or do you have a standalone (preferably minimal) test case we can try? It shouldn't use anything but core modules.

Also, did you search the bug tracker for similar reports? I remember there have been one or two but they turned out to be resource leaks in the application, not bugs in node.js.

@mike442144
Copy link
Author

mike442144 commented Nov 10, 2016

@bnoordhuis Actually, it is not a http issue, I have found the problem in tunnel-agent module, I'll close the issue first. thanks.

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

No branches or pull requests

4 participants