Monday, 06 July 2020
  1 Replies
  2.1K Visits
  Subscribe
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
3 years ago
·
#457
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
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf
· Insert · Remove
  Upload Files (Maximum 10MB)