TooTallNate / node-proxy-agent

Maps proxy protocols to `http.Agent` implementations
285 stars 69 forks source link

Timeout on proxy connect kills script #14

Closed jthomerson closed 1 year ago

jthomerson commented 7 years ago

I'll apologize in advance, because I hate submitting this kind of an issue - I can't find where the issue is, and it's totally possible that the issue is not with this library, but I'm not sure where to go next and hoping your expertise can help.

Some details:

When the proxy times out trying to connect, my long-running script that's using the AWS SDK just dies. There does not seem to be any error thrown, the SDK doesn't seem to retry, ... nothing. Compare this to if there's an actual error from the AWS API (any API) - I get an error that I can handle and move on. But when one of these proxy timeouts happens, the script dies with no indication of what went wrong.

I've tried the following:

var _ = require('underscore'),
    url = require('url'),
    proxy = require('proxy-agent'),
    awsOpts = {};

// try passing a timeout to the proxy-agent:
// see https://www.npmjs.com/package/agent-base#agentfunction-callback-object-options-→-httpagent
awsOpts.httpOptions = {
   agent: proxy(_.extend(url.parse('http://someproxy:3128'), { timeout: 30000 })),
};

// also try passing timeouts to the AWS options directly:
// see http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
awsOpts.connectTimeout = 30000;
awsOpts.timeout = 45000;

AWS.config.update(awsOpts);

Do you have any ideas on:

  1. what might be causing this, or
  2. how I could get an event or an error or something that I can log / debug when this happens?, or
  3. anything I might be missing?
lucacorti commented 6 years ago

I'm seeing the exact same thing and also have node deployed behind a squid proxy polling S3 for updated files. When internet connectivity is lost the polling fails and I have to restart node to make it work again.

TooTallNate commented 1 year ago

This code in this repository has been moved to the proxy-agents monorepo, so I am closing this pull request. If you feel that this issue still exists as of the latest release, feel free to open a new issue over there.