mckelvey / instagram-node-lib

The Instagram Node Lib is a helper library for node that makes communicating with the Instagram API easy.
http://david.mckelveycreative.com/
Other
303 stars 49 forks source link

instagram-node-lib not response after running for about an hours #22

Open songpr opened 10 years ago

songpr commented 10 years ago

I use the lib to retrieve instagram pics of a tag=love repeatedly. After running for about an hour. The lib is not response any more, no error throw ... just do nothing.

I've solved this by setting time out to http request in class.instagram.js below,

  InstagramAPI.prototype._request = function(params) {

      ...
      request.setTimeout( 10000, function( ) {
          request.abort();
      });
      if (post_data != null) {
        request.write(post_data);
      }
      request.addListener('error', function(connectionException) {
        if (connectionException.code !== 'ENOTCONN') {
          if (appResponse != null) {
            return error(connectionException, options, "_request", appResponse);
          } else {
            return error(connectionException, options, "_request");
          }
        }
      });