OS X 10.8.3

Node 0.10.0

I'm using the 'http' module to make requests of the Facebook graph API.

Here are the options that I pass to 'http.get':

var options = {host: 'graph.facebook.com',
               port: 80,
               path: '/' + fb_id + '/picture'};  //fb_id is a Facebook user identifier

My code looks like this:

http.get(options,
  function(res) {
    ...some stuff...
    DONE(RESULT);  //DONE is a callback function
  }).on('error', function(e) {
       ...some error handling...
});

What I observe is that I can only do as many requests as the value of http.globalAgent.maxSockets. Once I reach that many requests, the next call to http.get never (apparently) connects. I've verified that I'm not getting errors on the requests.

It's as though the sockets are not being closed after the response comes in.

Is there something I need to do as part of the response handler to ensure that the socket is closed?

Are these sockets not closing because of the default keepalive behavior?

How should I proceed to debug this?

Edit
Report