【问题标题】:S3 connector Issue with Akka stream - AlpakkaAkka 流的 S3 连接器问题 - Alpakka
【发布时间】:2018-06-19 11:46:21
【问题描述】:

我们正在使用 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)] 失败,因为 Some(10 seconds) 的连接超时已过期

代码 -

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

【问题讨论】:

  • “设置VPC代理”是指提供代理主机、端口以及是否应该使用https?
  • 它的代理服务器设置为访问组织内的任何 AWS 服务,如 S3。

标签: akka alpakka


【解决方案1】:

您可以在application.conf 中提供代理设置。加载此配置,并将其作为config 提供给您的ActorSystem(name, 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

【讨论】:

  • 感谢您的回复,只有当我尝试从本地系统连接到私有 VPC 中的 AWS 环境时,我才会收到此代理错误,如果我如上所述提供代理,它将创建我的 http基于该主机的 URL...在我的情况下,我想设置一些代理,例如“proxy.abc.company.com”,一旦我设置代理,那么我的存储桶 url 仍将是“buket-name.s3.amazonaws.com” “..
猜你喜欢
  • 2020-09-08
  • 1970-01-01
  • 2021-08-02
  • 1970-01-01
  • 2020-04-03
  • 2021-10-20
  • 2020-05-19
  • 1970-01-01
  • 2017-07-17
相关资源
最近更新 更多