@@ -311,6 +311,7 @@ int main(int argc, char *argv[])
311
311
std::promise<void > subscribeGetShadowRejectedCompletedPromise;
312
312
std::promise<void > onGetShadowRequestCompletedPromise;
313
313
std::promise<void > gotInitialShadowPromise;
314
+ bool isInitialShadowReceived = false ;
314
315
315
316
auto onGetShadowUpdatedAcceptedSubAck = [&](int ioErr) {
316
317
if (ioErr != AWS_OP_SUCCESS)
@@ -347,6 +348,15 @@ int main(int argc, char *argv[])
347
348
}
348
349
if (response)
349
350
{
351
+ // If another client requested shadow for the same thing at the same time, this callback might be
352
+ // triggered more than once. Ignore everything after first data arrived.
353
+ if (isInitialShadowReceived)
354
+ {
355
+ fprintf (stderr, " Initial shadow is already set, ignore\n " );
356
+ return ;
357
+ }
358
+ isInitialShadowReceived = true ;
359
+
350
360
fprintf (stdout, " Received shadow document.\n " );
351
361
if (response->State && response->State ->Reported ->View ().ValueExists (cmdData.input_shadowProperty ))
352
362
{
@@ -382,6 +392,15 @@ int main(int argc, char *argv[])
382
392
fprintf (stderr, " Error on getting shadow document: %s.\n " , ErrorDebugString (ioErr));
383
393
exit (-1 );
384
394
}
395
+ // If another client requested shadow for the same thing at the same time, this callback might be
396
+ // triggered more than once. Ignore everything after first data arrived.
397
+ if (isInitialShadowReceived)
398
+ {
399
+ fprintf (stderr, " Initial shadow is already set, ignore\n " );
400
+ return ;
401
+ }
402
+ isInitialShadowReceived = true ;
403
+
385
404
fprintf (
386
405
stdout,
387
406
" Getting shadow document failed with message %s and code %d.\n " ,
0 commit comments