Closed soundarsurya closed 6 years ago
Hi @soundarsurya ,
Thank you very much for using AWS IoT Device SDK for Node.js.
Looks like there are some connect option configuration issue with your client. There are 5 places that could possibly emit the error exceptions.INVALID_CONNECT_OPTIONS
:
https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L369
https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L445
https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L499
https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L504
https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L513
From the logs you provide, it would most likely be from the following two places: https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L369 https://github.com/aws/aws-iot-device-sdk-js/blob/master/device/index.js#L445
Can you share the options you used to initialize the client? It should look similar to what the sample shows:
const device = deviceModule({
keyPath: args.privateKey,
certPath: args.clientCert,
caPath: args.caCert,
clientId: args.clientId,
region: args.region,
baseReconnectTimeMs: args.baseReconnectTimeMs,
keepalive: args.keepAlive,
protocol: args.Protocol,
port: args.Port,
host: args.Host,
debug: args.Debug
});
Also, it seems that you are trying to use MQTT publish/subscribe within a lambda function. Note that AWS Lambda is event driven while MQTT requires a long live connection actively maintained to the cloud. Your lambda function will not be able to keep that long live MQTT connection for you. If you are only interested in publishing to a topic to AWS IoT, you can simply use the AWS SDK that uses HTTP(S).
Hope the above helps.
Thanks, Liusu
Thanks for the reply liusu, i didn't get what you say. so i have attached my whole module below. will you fix the error in my code. hope you reply and waiting for the message. thanks in advance.
On Thu, Jan 25, 2018 at 11:21 PM, Liusu Zeng notifications@github.com wrote:
Hi @soundarsurya https://github.com/soundarsurya ,
Thank you very much for using AWS IoT Device SDK for Node.js.
Looks like there are some connect option configuration issue with your client. There are 5 places that could possibly emit the error exceptions.INVALID_CONNECT_OPTIONS: https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L369 https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L445 https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L499 https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L504 https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L513
From the logs you provide, it would most likely be from the following two places: https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L369 https://github.com/aws/aws-iot-device-sdk-js/blob/master/ device/index.js#L445
Can you share the options you used to initialize the client? It should look similar to what the sample shows:
const device = deviceModule({ keyPath: args.privateKey, certPath: args.clientCert, caPath: args.caCert, clientId: args.clientId, region: args.region, baseReconnectTimeMs: args.baseReconnectTimeMs, keepalive: args.keepAlive, protocol: args.Protocol, port: args.Port, host: args.Host, debug: args.Debug });
Also, it seems that you are trying to use MQTT publish/subscribe within a lambda function. Note that AWS Lambda is event driven while MQTT requires a long live connection actively maintained to the cloud. Your lambda function will not be able to keep that long live MQTT connection for you. If you are only interested in publishing to a topic to AWS IoT, you can simply use the AWS SDK that uses HTTP(S).
Hope the above helps.
Thanks, Liusu
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-iot-device-sdk-js/issues/187#issuecomment-360545569, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahe8vE44sfGdsoahKcIHFhuZCotn4UWKks5tOL8HgaJpZM4RsZq7 .
Hi @soundarsurya ,
I am not able to see your module details. Can you include it directly in the reply?
Thanks, Liusu
yes liusu i have attached along with it..
if you not able to see then how can i send it to you..???
On Thu, Jan 25, 2018 at 11:56 PM, Liusu Zeng notifications@github.com wrote:
Hi @soundarsurya https://github.com/soundarsurya ,
I am not able to see your module details. Can you include it directly in the reply?
Thanks, Liusu
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-iot-device-sdk-js/issues/187#issuecomment-360555717, or mute the thread https://github.com/notifications/unsubscribe-auth/Ahe8vEl-tWpqfHxaQZsqinD1BLeOCNcvks5tOMdPgaJpZM4RsZq7 .
hi @liuszeng here is my module please have a look at it... AWS_test2.zip hope you get and fix my issue.
Hi @soundarsurya ,
It is really a bad idea to expose credentials on public places like Github. I have removed the link from your previous comment. I strongly recommend you to revoke any related credentials to prevent potential issues.
At the same time, I will take a look at the source and get back to you once I find something.
Thanks, Liusu
Hi @soundarsurya ,
In index.js
, you have the following lines:
var awsIot = require('aws-iot-device-sdk');
var deviceName = "myassistant";
var host = "<RANDOM_STRING1>.iot.us-east-1.amazonaws.com";
var app_id = "amzn1.ask.skill.<RANDOM_STRING2>";
var thingShadows = awsIot.thingShadow({
keyPath: './private.pem.key',
certPath: './certificate.pem.crt',
caPath: './rootCA.pem',
clientId: deviceName,
region: "us-east-1",
});
exports.handler = function (event, context) {
...
};
Can you try include host
and port
in the thingShadow
client initialization options? Your code should be like the following after the change:
var thingShadows = awsIot.thingShadow({
keyPath: './private.pem.key',
certPath: './certificate.pem.crt',
caPath: './rootCA.pem',
clientId: deviceName,
host: <YOUR_AWS_IOT_ENDPOINT>
});
By default, SDK will automatically use mutual authentication with certificate and configure the port for you once you have configured the host.
Hope the above helps.
Thanks, Liusu
hey @liuszeng thank you so much, after adding "host" in thingshadow i get successful. but one more doubt., i am not understand the line 19 to 24. and how our intent will be connect to thingshadow? line: 91 & 99.
hope you having my codes. waiting for reply....
thankyou,
in lambda function testing it gives execution result.(successful) how i check my function is working correctly.? how my skill is connect to thingshadow. when i revoke from my configured skill it shows "The remote endpoint could not be called, or the response it returned was invalid." like this... how to fix this.
@liuszeng may i get your mail ID because i can't wait so long to get help from you. if you feel nothing wrong just mail HI to "soundar.v1998@gmail.com" or else sorry for asking this....
why i am asking is i have been working in this for 1 month but no response for anyside. i get only from you.... so i can't wait till then.
thankyou,
@liuszeng waiting for your guideline......
Hi @soundarsurya ,
For Alexa related questions, I would encourage you to start a new thread in the corresponding AWS Forums. See the link below: https://forums.aws.amazon.com/forum.jspa?forumID=14
For Lambda related questions, I would encourage you to start a new thread in the corresponding AWS Forums. See the link below: https://forums.aws.amazon.com/forum.jspa?forumID=186
If you still have questions related to the SDK itself, please re-open this issue or create a new thread on the repository.
Thanks, Liusu
i have posted everywhere else but i didn't get any response. finally i get results from here. please let me help to finish my project.
thankyou
If you create the certificate in the aws iot console, then use the Amazon Root CA. See: https://docs.aws.amazon.com/iot/latest/developerguide/managing-device-certs.html
Node JS example. Download: https://www.amazontrust.com/repository/AmazonRootCA1.pem
var awsIot = require('aws-iot-device-sdk')
// Same params for: var thingShadows = awsIot.thingShadow({
var device = awsIot.device ({
keyPath: '/home/pi/certs/xxx-private.pem.key',
certPath: '/home/pi/certs/xxx-certificate.pem.crt',
caPath: '/home/pi/certs/AmazonRootCA1.pem',
clientId: 'MyPi',
region: 'us-west-2',
host: 'nnnnnnn-ats.iot.us-west-2.amazonaws.com'
});
device.on('connect', function() { console.log("Yes! Connected..."); });
finally when i run the lambda code i got the below error
{ "errorMessage": "Invalid connect options supplied.", "errorType": "Error", "stackTrace": [ "Function.DeviceClient (/var/task/node_modules/aws-iot-device-sdk/device/index.js:216:14)", "new ThingShadowsClient (/var/task/node_modules/aws-iot-device-sdk/thing/index.js:123:30)", "Object.ThingShadowsClient [as thingShadow] (/var/task/node_modules/aws-iot-device-sdk/thing/index.js:89:14)", "Object. (/var/task/index.js:6:27)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)"
]
}
how could it be fixed...????