title: Publish mqtt message to topic from aws lambda using aws iot
body: <p>I need to publish data from aws lambda through mqtt protocol using aws iot. i have created a lambda function with node.js code. like this </p>
  
  <pre><code>exports.handler = (event, context, callback) =&gt; {
  
      var awsIot = require('aws-iot-device-sdk');
  
      var device = awsIot.device({
          keyPath: 'samplepath/test.pem.key',
          certPath: 'samplepath/test.crt',
          caPath: 'samplepath',
          clientId: 'sampleId',
          region: 'us-east-1'
      });
  
      device
          .on('connect', function () {
              console.log('connected');
              device.publish('test_topic', JSON.stringify({ "test_name": "hello", "test_value": 1001 }));
              console.log('published successfully');
              callback(null, 'item added');
          });
  }
  </code></pre>
  
  <p>I got mqtt message on subscriber. but lambda produce error message like this</p>
  
  <pre><code>Task timed out after 10.00 seconds 
  </code></pre>
  
  <p>I have used context.succeed() instead of callback, lambda is exited properly. i cant get any messages on subscriber.</p>
  
  <p>In both cases console prints <em>published successfully</em> message properly. </p>
  
  <p>What is the issue related with my publishing code?</p>