title: AWS Greengrass V2 Node Publishing problem with aws-iot-sdk-v2 JS
body: <p>For the past few days I've been trying to solve the problem of publishing a message from Lambda to the AWS cloud, using Greengrass v2.</p>
  <p>The code in python was even provided in the documentation, only had to be slightly reworked.</p>
  <p>When it comes to SDK v2 JS in documentation there is only minimal mention about publish function in AWS-CRT library.</p>
  <p>I tried to create code using components from this library, but it looks like the library also requires a script with parameters.</p>
  <p>This is my code that requires installation of aws-iot-sdk-v2 js.</p>
  <pre><code>const iotsdk = require(&quot;aws-iot-device-sdk-v2&quot;);
  const mqtt = iotsdk.mqtt;
  const os = require(&quot;os&quot;);
  const util = require(&quot;util&quot;);
  
  const GROUP_ID = process.env.GROUP_ID;
  const THING_NAME = process.env.AWS_IOT_THING_NAME;
  const THING_ARN = process.env.AWS_IOT_THING_ARN;
  
  (topic = &quot;gg/message&quot;),
  (payload = JSON.stringify({ message: util.format(&quot;ping&quot;) }));
  
  function greengrassHelloWorldRun() {
     mqtt.MqttClientConnection.prototype.publish(topic, payload);
    }
    console.log(topic);
      console.log(payload);
  
   setInterval(greengrassHelloWorldRun, 5000);
  
    exports.handler = function (event, context) {
     console.log(&quot;event: &quot; + JSON.stringify(event));
    console.log(&quot;context: &quot; + JSON.stringify(context));
    };
  </code></pre>
  <p>I get errors about arguments and NAPI.</p>
  <p>The same errors also appear when using this function as lambda component in greengrass logs</p>
  <p>Maybe someone has some example how to publish some message on topic using Node lambda with sdk v2.</p>