When using the AmazonS3
object for the first time after the application starts, there is a large delay of approx 14 seconds. This large time delay is not present for all subsequent calls.
I have encountered this exact delay issue before with other HTTP related classes and it is caused when the class in question tries to determine the local machine's proxy settings and whether to use them or not.
To stop this from happening with WebClient
, you set WebClient.Proxy = null;
and it doesn't try to auto detect the proxy settings, but I cannot figure out how to disable the proxy detection functionality of the AmazonS3
object.
I have specifically tried setting the ProxyHost
to null
:
_s3Client = AWSClientFactory.CreateAmazonS3Client(awsAccessKey, awsSecretAccessKey, new AmazonS3Config { ProxyHost = null });
Which didn't work. We are currently using the Amazon .NET SDK 'v1.3.17.0'.
Is there a way to turn off the proxy detection?
Good question - I haven't tried it myself and only analyzed the code, but the AmazonS3Config Class uses a private method
configureWebRequest()
, which in turn relies on the WebRequest Class to handle the actual HTTP connection. Now,WebRequest
has a WebRequest.DefaultWebProxy Property , which is public static (i.e. you can set this within your application before callingCreateAmazonS3Client(()
) :The proxy auto detection you are experiencing is supposedly induced by the respective IE behavior:
Consequently I'd hope that this can be disabled in a similar way as for the WebClient.Proxy Property you mentioned, albeit on the class level, as indeed strongly suggested by the last paragraph:
Added by blexandre
sample code from this answer would be
Note that this will disable the proxy for every web request,
_client
is created using it, so it is safe to do this, but be careful if you might have more requests pending from theWebRequest
class