Akka流的S3连接器问题-Alpakka

时间:2018-06-19 11:46:21

标签: akka alpakka

我们正在使用Alpakka s3连接器从VPC内的本地系统连接到s3存储桶,并出现以下错误,如果使用传统的aws客户端库,我们可以连接到s3并下载文件,我还附加了示例代码我们用于alpakka s3连接器。 这是因为我必须在代码中设置一些VPC代理使用我的传统aws s3库,但是我看不到alpakka给出了设置我的VPC代理的选项吗?

错误- akka.stream.StreamTcpException:Tcp命令[Connect(bucket-name.s3.amazonaws.com:443,None,List(),Some(10 seconds),true)]失败,因为某些(10秒)的连接超时已过期

代码-

  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
  }
  }

1 个答案:

答案 0 :(得分:0)

您可以在application.conf中提供代理设置。加载此配置,并将其作为ActorSystem(name, config)提供给您的config

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

以下任何配置设置都可以在您的application.conf中覆盖:https://github.com/akka/alpakka/blob/master/s3/src/main/resources/reference.conf#L8