Amazon web services 尝试从我的Flatter应用程序访问AWS EC2服务器时,我收到[SocketException:OS错误:连接被拒绝,errno=111]

Amazon web services 尝试从我的Flatter应用程序访问AWS EC2服务器时,我收到[SocketException:OS错误:连接被拒绝,errno=111],amazon-web-services,http,flutter,amazon-ec2,flutter-web,Amazon Web Services,Http,Flutter,Amazon Ec2,Flutter Web,我无法连接到在AWS EC2实例上运行的REST API服务器 下面是颤振应用程序的代码片段 final EC2ServerPublicDNS = "http://ec2-*****.amazonaws.com"; final awsSigV4Client = new AwsSigV4Client( IAMUserAccessKey, IAMUserSecretKey, EC2ServerPublicDNS, region: reg

我无法连接到在
AWS EC2
实例上运行的
REST API服务器

下面是颤振应用程序的代码片段

final EC2ServerPublicDNS = "http://ec2-*****.amazonaws.com";
final awsSigV4Client = new AwsSigV4Client(
        IAMUserAccessKey,
        IAMUserSecretKey,
        EC2ServerPublicDNS,
        region: region);
final signedRequest = new SigV4Request(
      awsSigV4Client,
      method: 'GET',
      path: '/test',
      headers:
          new Map<String, String>.from({"Content-Type": "application/json"}),
    );
    http.Response response;
    try {
      response =
          await http.get(signedRequest.url, headers: signedRequest.headers);
    } catch (e) {
      print(e);
    }
final EC2ServerPublicDNS=”http://ec2-*****.amazonaws.com”;
最终AWSSIGV4客户端=新的AWSSIGV4客户端(
IAMUserAccessKey,
IAMUserSecretKey,
EC2ServerPublicDNS,
地区:地区),;
final signedRequest=新的SIGV4请求(
AWSSIGV4客户,
方法:“GET”,
路径:'/test',
标题:
新映射。从({“内容类型”:“application/json”}),
);
http.响应;
试一试{
回应=
等待http.get(signedRequest.url,headers:signedRequest.headers);
}捕获(e){
印刷品(e);
}
我得到:

[SocketException:OS错误:连接被拒绝,错误号=111,地址=ec2-*****.amazonaws.com,端口=33278]


在您的android清单文件中授予
权限。

这是我以前做过的