* @param ec2client AmazonEC2Client object
*/
private void checkConnection(Instance instance, AmazonEC2Client ec2client) {
/* Make sure port 22 is connectible */
for (GroupIdentifier g : instance.getSecurityGroups()) {
IpPermission ip = new IpPermission();
ip.setIpProtocol("tcp");
ip.setFromPort(SSH_PORT);
ip.setToPort(SSH_PORT);
AuthorizeSecurityGroupIngressRequest r = new AuthorizeSecurityGroupIngressRequest();
r = r.withIpPermissions(ip.withIpRanges("0.0.0.0/0"));
r.setGroupId(g.getGroupId());
try {
ec2client.authorizeSecurityGroupIngress(r);
} catch (AmazonServiceException as) {
/* If exception is from duplicate room, ignore it. */