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

Consistent socket hang up errors #199

Open
MeanwhileMedia opened this issue Jun 7, 2014 · 6 comments
Open

Consistent socket hang up errors #199

MeanwhileMedia opened this issue Jun 7, 2014 · 6 comments

Comments

@MeanwhileMedia
Copy link

Hi,
I'm using node-auth through twit and keep getting socket hang ups when trying to close, then reopen a connection to the streaming api. Not sure if the problem starts here, or is in Twit, so I thought I'd ask around.

Here is the issue I opened on twit's repo: ttezel/twit#117

I am also wondering if this known issue may be related: nodejs/node-v0.x-archive#5360

I added a log in your ._createClient method as so:

  oauthRequest.on('error', function(e) {
    console.error('OauthRequest error: ', e);
  });

The reported error is:

OauthRequest error:  { [Error: socket hang up] code: 'ECONNRESET', sslError: undefined }

I also tried updating the request options to reflect the solution stated in issue 5360 (linked above):

  var options = {
    host: hostname,
    port: port,
    path: path,
    method: method,
    headers: headers,
    secureProtocol: 'SSLv3_method',
    secureOptions: constants.SSL_OP_NO_TLSv1_2
  };

This seemed to make no difference, and did not stop the socket hang ups.

Any ideas?
Thanks

@ciaranj
Copy link
Owner

ciaranj commented Jun 7, 2014

Not sure its anything that node-oauth can specifically control, more likely an issue in node itself (or dependent ssl libraries) ? Not an SSL expert unfortunately, I guess you could check the certs coming from the endpoint address and check them using the openssl verify apps ?

@MeanwhileMedia
Copy link
Author

Thanks @ciaranj, I'll break out openssl to see if I can figure anything out related to the certs. I'm also wondering if this may be related to some sort of cryptic rate limiting from Twitter. I'll let you know if I come across anything.

@ciaranj
Copy link
Owner

ciaranj commented Jun 7, 2014

np. Sorry I couldn't be more use :/ seems a bit weird to be rate related,
I'd jump back a version of node just to check that first?

On Saturday, June 7, 2014, Joe Webb notifications@github.com wrote:

Thanks @ciaranj https://github.com/ciaranj, I'll break out openssl to
see if I can figure anything out related to the certs. I'm also wondering
if this may be related to some sort of cryptic rate limiting from Twitter.
I'll let you know if I come across anything.


Reply to this email directly or view it on GitHub
#199 (comment).

@raoulmillais
Copy link
Contributor

This is likely being caused by the http request connection pooling. We had this issue in production as well and disabling the agent on non-oauth requests made a big difference. Our monitoring is still showing a lot of needless request queuing for the secure requests though

Adding agent: false in _createClient should fix it. I've done this in my fix-socket-hangups branch but I'm not sure how to test it other than putting it in production and monitoring. Maybe this should be configurable also?

@raoulmillais
Copy link
Contributor

In case anyone else stumbles across this, these settings can also be changed for the global agents. This will, of course, affect all outbound http(s) connections:

var http = require('http');
var https = require('https');
http.globalAgent.maxSockets = 100;
https.globalAgent.maxSockets = 100;

where 100 is the number of concurrent connections before queuing

@MeanwhileMedia
Copy link
Author

awesome thanks @raoulmillais

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

3 participants