gpt4 book ai didi

java - 用于 S3 服务的 java amazon SDK 中的连接被拒绝

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:27:13 24 4
gpt4 key购买 nike

我正在编写命令行工具来管理 S3 服务。在我的本地机器上,一切正常,但在应该执行它的服务器上,失败并显示以下消息:

Error Message: Unable to execute HTTP request: Connection to http://s3.amazonaws.com refused

我用下面的代码建立连接:

 s3  = new AmazonS3Client(credentials,clientConf);

clientConf 仅将协议(protocol)设置为 HTTP,因为我怀疑连接到 HTTPS 可能会出现问题,但我得到了相同的结果。

现在,服务器有如下配置:

debian 6 64 位

从源安装 LAMP

从源代码安装的 openssl

从分发包包安装的java

这是网络配置:

    auto eth0
iface eth0 inet static

address XX.XX.XX.XX
netmask 255.255.255.255
broadcast XX.XX.XX.XX (same as address)

auto eth0:0
iface eth0:0 inet static

address XX.XX.XX.XX
netmask 255.255.255.255
broadcast XX.XX.XX.XX (same as address)

auto eth0:1
iface eth0:1 inet static

address XX.XX.XX.XX
netmask 255.255.255.255
broadcast XX.XX.XX.XX (same as address)

post-up route add 10.255.255.1 dev eth0
post-up route add default gw 10.255.255.1

wget、telnet、curl,一切正常,除了这个,我有 3 个网络接口(interface),因为我有 2 个 SSL 和另一个用于其他站点的 ip。

我应该如何配置 clientConf 以使其工作?是java问题吗?网络问题?至少,我如何获得更多调试信息?我试图捕获 AmazonClientException 异常,但没有成功。

提前致谢:)

问候。

最佳答案

This has been reported as a bug in the Amazon S3 API .郭思ZachM@AWS :

This appears to be a bug in the SDK. The problem is that the client configuration object is shared with the Security Token Service client that DynamoDB uses to establish a session, and it (unlike Dynamo) doesn't accept the HTTP protocol. There are a couple workarounds:

1) Create your own instance of STSSessionCredentialsProvider and provide it to your DynamoDB client, or

2) Instead of specifying the protocol in the ClientConfiguration, specify it with a call to setEndpoint("http://...")

We'll discuss solutions for this bug.

我建议暂时使用其中一种解决方法。祝你的连接成功运行。

( Additional documentation and workarounds )

关于java - 用于 S3 服务的 java amazon SDK 中的连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9863068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com