By Guest on Monday, 06 July 2020
Posted in General
Replies 1
Likes 0
Views 2.3K
Votes 0
Hi there!

I'm trying to connect to my AWS IoT but always getting disconnect after trying to connect

//AWS_Client1: TsgcIoTAmazon_MQTT_Client; // Using component from pallete

AWS_Client1.Amazon.Endpoint := 'a2v182i8gsqb1o-ats.iot.eu-west-1.amazonaws.com';
AWS_Client1.Amazon.ClientId := 'sgcWebSockets';
AWS_Client1.Amazon.Port:= 8883;
AWS_Client1.Certificate.CertFile:='C:\7db46775ee-certificate.pem.crt';
AWS_Client1.Certificate.KeyFile := 'C:\7db46775ee-private.pem.key';
AWS_Client1.Active := True;

This is my code... Sure all certificates are valid.

Any ideas??
Ramon
Hi,

Most probably you can connect because you are not authorized. When you connect using port 8883 and use TCP as transport (which is the default), amazon takes "AWS IoT Core policy" to provide or not authorization to clients and subscriptions. Most probably you must authorize your client id.

Enter in your Amazon AWS console, go to IoT Core and access menu "Secure/Policies", there select the policy attached to your IoT Thing and check at the end how connection is configured. Example:


{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"arn:aws:iot:us-east-1:222178873557:client/sdk-java",
"arn:aws:iot:us-east-1:222178873557:client/basicPubSub",
"arn:aws:iot:us-east-1:222178873557:client/sdk-nodejs-*"
]
}


This configuration means that only clients with ID: sdk-java, basicPubSub and sdk-nodejs-* will be allowed to connect. Change accordingly and try again.
If still doesn't work, enable log and check in cloudwatch the reason why you can't connect.

Kind Regards,
Sergio
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post