Closed rahulkai closed 6 years ago
Hi @rahulkai ,
As I mentioned in post #43 , AWS IoT has the limit of 50 subscriptions per connection (mentioned in AWS servicel limits), which means you can only manage 7 device shadows within the same connection. To go beyond that, what you can do is to create different client connections to AWS IoT and register your things correspondingly to each connection. More details and sample can be found in the same post.
If you want a account level service limit increase, you can use the following link to make a request to AWS IoT; https://aws.amazon.com/contact-us/
Hope the above helps.
Thanks, Liusu
Hi @liuszeng ,
...
var iotShadowConnectionGroup1 = awsIot.thingShadow(iotconfigParams1);
var iotShadowConnectionGroup2 = awsIot.thingShadow(iotconfigParams2);
...
iotShadowConnectionGroup1.on("connect", function () {
console.log("Connected to AWS-iot");
});
iotShadowConnectionGroup1.on("status", function (thingName, stat, clientToken, stateObject) {
console.log("thingName: " + thingName + "\n stat: " + stat + "\n clientToken: " + clientToken + "\n stateObject: " + JSON.stringify(stateObject));
});
iotShadowConnectionGroup1.on("timeout", function(thingName){
console.log("Time out for " + thingName);
});
iotShadowConnectionGroup2.on("connect", function () {
console.log("Connected to AWS-iot");
});
iotShadowConnectionGroup2.on("status", function (thingName, stat, clientToken, stateObject) {
console.log("thingName: " + thingName + "\n stat: " + stat + "\n clientToken: " + clientToken + "\n stateObject: " + JSON.stringify(stateObject));
});
iotShadowConnectionGroup2.on("timeout", function(thingName){
console.log("Time out for " + thingName);
});
This will be a static variable if i want to subscribe thousands of connection this will have multiple variable any example or solution to optimize this code.
Thanks, Rahul
Hi @rahulkai ,
That really depends on how you want to structure your system. One thing you can do is to create your own shadow client vendor that keeps track of the total number of shadows you are tracking (subscribing to 7 topics for each) and allocate a new client connection once that limit is reached. Something similar to the following:
const MAX_NUM_SHADOWS_PER_CONNECTION = 7;
var numShadowsInThisConnection = 0;
// On a new shadow registration request
if (numShadowsInThisConnection == MAX_NUM_SHADOWS_PER_CONNECTION) {
var newId = createNewId();
shadowClients[someId] = awsIot.thingShadow();
// Now configure the event callbacks for this client
...
shadowClients[someId].register(thingName);
numShadowsInThisConnection = 1;
} else {
var existedId = getExistedId(thingName);
var shadowClient = shadowClients[existedId];
shadowClient.register(thingName);
numShadowsInThisConnection += 1;
}
...
That being said, I am not sure if this is the right way when it comes to thousands of connections/clients/things like you mentioned. Putting all these into a single process will soon bring you other problems like limit of number of available sockets/ports etc.
Again, if you want a account level service limit increase, you can use the following link to make a request to AWS IoT: https://aws.amazon.com/contact-us/
Thanks, Liusu
Please open another thread if you still have questions.
Hi,
As mentioned in the below thread we can only subscribe to 7 shadows by changing client id this can be increased.I want this process to be dynamic to register more the 100 thing.
https://github.com/aws/aws-iot-device-sdk-js/issues/43
Thanks