title: how to check if AmazonS3Client connection is active or not
body: <p>I am looking to develop a Singletone AmazonS3Client that serves my application to upload files to Amazon S3 server. however, I couldn't find how to check if the connection is active and able to upload buckets or not.</p>
  
  <p>are there specific Exception that would be thrown if the connection dropped? or does the connection get dropped after certain period of time?</p>
  
  <p>any answer would help.</p>
  
  <p>here is snippet of my code:</p>
  
  <pre><code>private static final AmazonS3Client s3Client;
  static {
    AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
    s3Client = new AmazonS3Client(awsCredentials);
  }
  
  private static boolean writeFile(AmazonS3Client s3Client, String fileName, File file, Boolean publicRead){
    try {
      PutObjectRequest p = new PutObjectRequest(bucketName, fileName, file);
      if (publicRead)
        p.setCannedAcl(CannedAccessControlList.PublicRead);
      s3Client.putObject(p);
      System.out.println("URL: " + S3_BASE_URL + fileName);
      return true;
    } catch (AmazonServiceException ase){
      ase.printStackTrace();
    } catch (AmazonClientException ace) {
      ace.printStackTrace();
    } catch (Exception ex){
      ex.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
    }
    return false;
  }
  </code></pre>