title: AWS Maximum number of retry attempts reached : 3
body: <p>I hosted simple web application in amazon cloud.I am facing problem reading the bucket object in my hosted webapplication.I got the error in the below line, when i tried to create the,</p>
  
  <p><strong>GetObjectResponse response = client.GetObject(request);</strong></p>
  
  <p>Error:
  Maximum number of retry attempts reached : 3</p>
  
  <p>Even i tried with increasing the MaxErrorRetry = 5 but still am getting the problem</p>
  
  <p>*<em>If anyone can help me here I'd greatly appreciate it, thanks :) *</em></p>
  
  <p>Below is the <strong>source code</strong>:</p>
  
  <pre><code>public class HomeController : Controller
  {
      static string keyName = "";
      static AmazonS3 client;
  
      public ActionResult Index()
      {
          ViewBag.Message = "Welcome to ASP.NET MVC!";
  
          string data = readCloudData("filename.txt");
  
          ViewBag.Message = data;
          return View();
      }
  
      public ActionResult About()
      {
          return View();
      }
  
      public string readCloudData(string objName)
      {
          string data = string.Empty;
          if (checkRequiredFields(objName))
          {
              NameValueCollection appConfig = ConfigurationManager.AppSettings;
  
              string accessKeyID          = appConfig["AWSAccessKey"];
              string secretAccessKeyID    = appConfig["AWSSecretKey"];
              string bucketName           = appConfig["AWSBucketName"];
  
              try
              {
                  data = ReadingAnObject(accessKeyID, secretAccessKeyID, bucketName, objName);
              }
              catch (AmazonS3Exception s3Exception)
              {
                  return "Error in reading file!";
              }
          }
          data = data.Trim();
          return data;
      }
  
      static string ReadingAnObject(string accessKeyID, string secretAccessKeyID, string bucketName, string keyName)
      {
          string responseBody = "";           
          using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(
                                           accessKeyID, secretAccessKeyID))
          {
              GetObjectRequest request = new GetObjectRequest()
                  .WithBucketName(bucketName).WithKey(keyName);
              try
              {
                  using (GetObjectResponse response = client.GetObject(request))
                  {             
  
                      using (Stream responseStream = response.ResponseStream)
                      {
                          using (StreamReader reader =
                              new StreamReader(responseStream))
                          {
                              responseBody = reader.ReadToEnd();
                          }
                      }
                  }
  
              }
              catch (AmazonS3Exception s3Exception)
              {
  
                  return s3Exception.Message;
              }
          }
          return responseBody;
      }
  
      static bool checkRequiredFields(string keyName)
      {
          NameValueCollection appConfig = ConfigurationManager.AppSettings;
  
          if (string.IsNullOrEmpty(appConfig["AWSAccessKey"]))
          {
              return false;
          }
          if (string.IsNullOrEmpty(appConfig["AWSSecretKey"]))
          {
              return false;
          }
          if (string.IsNullOrEmpty(appConfig["AWSBucketName"]))
          {
              return false;
          }
          if (string.IsNullOrEmpty(keyName))
          {
              return false;
          }
  
          return true;
      }
  }
  </code></pre>