title: Using MQTT client in firebase cloud functions
body: <p>I have a firebase project (blaze plan) and firestore database.
  I need to use mqtt client in cloud functions.</p>
  <p>But when I add this line</p>
  <pre><code>const mqtt = require('mqtt');
  </code></pre>
  <p>to index.js, it can not be deployed to firebase.</p>
  <p>It gives this error:</p>
  <blockquote>
  <p>{&quot;@type&quot;:&quot;type.googleapis.com/google.cloud.audit.AuditLog&quot;,
  &quot;status&quot;:{&quot;code&quot;:3,</p>
  <p>&quot;message&quot;:&quot;Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: <a href="https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs" rel="nofollow noreferrer">https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs</a>. Additional troubleshooting documentation can be found at <a href="https://cloud.google.com/functions/docs/troubleshooting#logging" rel="nofollow noreferrer">https://cloud.google.com/functions/docs/troubleshooting#logging</a>. Please visit <a href="https://cloud.google.com/functions/docs/troubleshooting" rel="nofollow noreferrer">https://cloud.google.com/functions/docs/troubleshooting</a> for in-depth troubleshooting documentation.&quot;},</p>
  <p>&quot;authenticationInfo&quot;:{&quot;principalEmail&quot;:&quot;<em>myMail</em>&quot;},&quot;serviceName&quot;:&quot;cloudfunctions.googleapis.com&quot;,&quot;methodName&quot;:&quot;google.cloud.functions.v1.CloudFunctionsService.UpdateFunction&quot;,&quot;resourceName&quot;:&quot;projects/<em>myProject</em>&quot;}</p>
  </blockquote>
  <p>my code:</p>
  <pre><code>const functions = require(&quot;firebase-functions&quot;);
  const admin = require('firebase-admin');
  
  **const mqtt = require('mqtt');**
  
  admin.initializeApp();
  
  const db = admin.firestore();
  </code></pre>
  <p>Is there any solution to use mqtt package in google cloud functions?</p>
  <p>I appreciate any help. thanks.</p>