我正在关注以下链接https://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html 将文件从本地计算机上传到VPC上的S3存储桶。该应用程序还在内部部署机器上进行测试和运行。
var s3Client = new AmazonS3Client(RegionEndpoint.USEast2);
var fileTransferUtility = new TransferUtility(s3Client);
await fileTransferUtility.UploadAsync("c:\tmp\test.txt", "bucketName");
但是,代码出现以下错误。
尝试对不可达的网络进行套接字操作
是否应提供网址?
这是Fiddler捕获的网络流量。但是,它为代码提供了不同的例外。
GET http://1xx.1xx.1xx.2xx/latest/meta-data/iam/security-credentials HTTP/1.1 Host: 1xx.1xx.1xx.2xx HTTP/1.1 503 Service Unavailable Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Length: 787 Network Error
Network Error (tcp_error)
A communication error occurred: "Operation timed out" The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
For assistance, contact your network support team.
.aws\config
[default]
region = USWest2
答案 0 :(得分:2)
即使我有一个有效的$USERPROFILE\.aws\credentials
文件,今天我仍然遇到相同的错误-实际上是因为$USERPROFILE\AppData\Local\AWSToolkit\RegisteredAccounts.json
无法解密(不确定原因),这导致AWS认为您没有这样做没有本地凭据,因此尝试建立与http://169.254.169.254/latest/meta-data/?的EC2元数据URL的连接。在无法访问的本地开发计算机上。对我来说,删除$USERPROFILE\AppData\Local\AWSToolkit\RegisteredAccounts.json
文件可以解决问题。 FWIW,我只能通过阅读AWS开发工具包的源代码来解决这个问题。