AWS lambda publishes repeated messages to mqtt topic

My flow include
AWS IOT>> IOT Rules >> (AWS Lambda & Dynamo DB) >> MQTT topic

Device sends data to IOT and based on the rules will get inserted to Dynamodb and will be going to Lambda function.Lambda function will send the response back to device through mqtt topic.

Bullet points

  1. lambda function is in Nodejs and using “aws-iot-device-sdk” for connecting & publishing to mqtt
  2. every device will have its own mqtt topic where lambda function will publish messages and be subscribed by particular device

Problem : below is my code snippets for connect & publish message

_device.on('connect', function(connack) {_

_ device.publish(clientid,responsestring,function(cb){_
_ callback(‘done’);_
_ }); _
_ });_

But I am finding that these particular lines are sometimes executing multiple times (sometimes : not consistently)