Learner
Learner

Reputation: 45

S3 connector Issue with Akka stream - Alpakka

We are using Alpakka s3 connector to connect to s3 bucket from local system within VPC and getting error as below ,if we use our tradition aws client library we are able to connect to s3 and download file , I am also attaching sample code we are using for alpakka s3 connector. Is this error because i have to setup some VPC proxy in Code which i use to do with our traditional aws s3 library but i dont see alpakka give option to setup my VPC proxy ?

Error - akka.stream.StreamTcpException: Tcp command [Connect(bucket-name.s3.amazonaws.com:443,None,List(),Some(10 seconds),true)] failed because of Connect timeout of Some(10 seconds) expired

Code -

  override def main(args: Array[String]): Unit = {
  implicit val system = ActorSystem()
  implicit val materializer = ActorMaterializer()
  implicit val executionContext: ExecutionContext = 
  ExecutionContext.Implicits.global

  val awsCredentialsProvider = new AWSStaticCredentialsProvider(
  new BasicSessionCredentials("xxxxxx", "xxxx", "xxxx")
  )
  val regionProvider =
  new AwsRegionProvider {
    def getRegion: String = "us-east-1"
  }
  val settings =
  new S3Settings(MemoryBufferType, None, awsCredentialsProvider, 
  regionProvider, false, None, ListBucketVersion2)
  val s3Client = new S3Client(settings)(system, materializer)
  val future = s3Client.download("bucket_name", "Data/abc.txt", None, 
  Some(ServerSideEncryption.AES256)) 
  future._2.onComplete {
    case Success(value) => println(s"Got the callback, meaning = 
   value")
    case Failure(e) => e.printStackTrace
  }
  }

Upvotes: 0

Views: 845

Answers (1)

emran
emran

Reputation: 922

You can provide proxy settings in application.conf. Load this config, and provide it to your ActorSystem(name, config) as the config.

akka.stream.alpakka.s3 {
  proxy {
    host = ""
    port = 8000
    # use https?
    secure = true
  }
}

any of the following configuration settings can be overridden in your application.conf: https://github.com/akka/alpakka/blob/master/s3/src/main/resources/reference.conf#L8

Upvotes: 0

Related Questions