AmazonEc2Client 实例如何处理网络中断?

How does an instance of the AmazonEc2Client deal with network interruptions?

我们正在使用 AWS SDK 与 AWS 交互。例如,创建、停止和重启 ec2 实例。第一步如果实例化客户端,然后就可以使用了,但是我相信如果客户端实例化后网络连接失败,那么这个实例就不能再使用了。但是,可能是实例在重新启用连接后正在再次连接到 AWS,并且此过程需要几秒钟。所以我想知道是否有人可以描述这个 class.

的预期行为

大多数 AWS SDK 会在网络中断或命令限制的情况下自动重试命令。但是,如果 SDK 仍然无法执行它们的操作,它们将失败并且 return 错误代码返回给您。错误代码 returned 取决于实际发生的故障。所以你需要处理出错的可能性。

使用它来引用 SDK 可以使用的各种错误代码return:

http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html

I believe if the network connection fails after the client is instantiated, that instance can no longer be used.

不正确。如果连接失败,该命令将 return 一个错误代码,但您可以使用同一客户端重试该命令(或发出不同的命令)。

However, it might be the instance is in the process of connecting to AWS again after the connection

SDK 客户端不会保持与 AWS 的持续连接。当您调用 SDK 上的函数时,它才会连接到 AWS 以执行请求的操作。