Reputation: 87
I cannot connect to the REST API Server
running on a AWS EC2
instance.
Below is the code snippet from the flutter application.
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);
}
I am getting:
[SocketException: OS Error: Connection refused, errno = 111, address = ec2-*****.amazonaws.com, port = 33278]
Upvotes: 1
Views: 479
Reputation: 978
give permission of <uses-permission android:name="android.permission.INTERNET" />
in your android Manifest file.
Upvotes: 0