【问题标题】:I am getting [SocketException: OS Error: Connection refused, errno = 111] when trying to access AWS EC2 server from my flutter app我在尝试从我的 Flutter 应用程序访问 AWS EC2 服务器时收到 [SocketException: OS Error: Connection denied, errno = 111]
【发布时间】:2020-04-15 07:41:39
【问题描述】:

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

下面是来自 Flutter 应用的代码 sn-p。

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);
    }

我得到:

[SocketException:操作系统错误:连接被拒绝,errno = 111,地址 = ec2-*****.amazonaws.com,端口 = 33278]

【问题讨论】:

    标签: amazon-web-services http flutter amazon-ec2 flutter-web


    【解决方案1】:

    在您的 android Manifest 文件中授予 &lt;uses-permission android:name="android.permission.INTERNET" /&gt; 的权限。

    【讨论】:

    • 这个我以前做过
    猜你喜欢
    • 2020-05-16
    • 1970-01-01
    • 2020-09-07
    • 2020-05-26
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    相关资源
    最近更新 更多