>我无法连接到AWS EC2
实例上运行的REST API Server
。
下面是来自颤振应用程序的代码片段。
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);
}
我得到:
[套接字异常:操作系统错误:连接被拒绝,errno = 111,地址 = ec2-*****.amazonaws.com,端口 = 33278]
在您的 android 清单文件中授予<uses-permission android:name="android.permission.INTERNET" />
权限。