title: I have Created a Whatsapp Clone using MERN Stack. Facing Errors in backEnd side
body: <p>I have created a WhatsApp clone in the backend of Whatsapp clone i am facing following errors.
  when i run yarn start i am facing following errors in console.</p>
  <pre><code>        yarn start
  yarn run v1.23.0-20200615.1913
  
  
  
    $ node server.js
  (node:4316) [MONGODB DRIVER] Warning: the options [useUnifedTopology] is not supported
  (Use `node --trace-warnings ...` to show where the warning was created)
  listen on local host 6000
  </code></pre>
  <p>(node:4316) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.</p>
  <pre><code>E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\topologies\server.js:441
            new MongoNetworkError(
            ^
  
  MongoNetworkError: failed to connect to server [cluster0-shard-00-01.ngclm.mongodb.net:27017] on first connect [MongoError: bad auth : Authentication failed.
      at Connection.messageHandler (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:362:19)
      at Connection.emit (node:events:390:28)
      at processMessage (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:454:10)
      at TLSSocket.&lt;anonymous&gt; (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:623:15)
      at TLSSocket.emit (node:events:390:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:199:23) {
    ok: 0,
    code: 8000,
    codeName: 'AtlasError'
  }]
      at Pool.&lt;anonymous&gt; (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\topologies\server.js:441:11)
      at Pool.emit (node:events:390:28)
      at E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\pool.js:564:14
      at E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\pool.js:1013:9
      at callback (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connect.js:75:5)
      at E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connect.js:147:27
      at E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\auth\scram.js:109:14
      at _callback (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:331:7)
      at Connection.messageHandler (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:362:9)
      at Connection.emit (node:events:390:28)
      at processMessage (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:454:10)
      at TLSSocket.&lt;anonymous&gt; (E:\Whatapp clone\whatsapp-backend\node_modules\mongodb\lib\core\connection\connection.js:623:15)
      at TLSSocket.emit (node:events:390:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
  </code></pre>
  <p>My main file Server.js (It is the main file )</p>
  <pre><code>// Import
  
  import express from &quot;express&quot;;
  import mongoose from &quot;mongoose&quot;;
  import Messages from './dbMessages.js';
  import Pusher from &quot;pusher&quot;;
  import cors from &quot;cors&quot;;
  
  import axios from &quot;axios&quot;;
  
  // app config
  const app = express();
  const port = process.env.PORT || 6000;
  
  // Pusher code
  const pusher = new Pusher({
      appId: &quot;1366318&quot;,
      key: &quot;eb9c7412499f6e7b4c5f&quot;,
      secret: &quot;6903a1ffa86fcb2c3ddd&quot;,
      cluster: &quot;ap2&quot;,
      useTLS: true
    });
    
  // middle ware
  app.use(express.json());
  app.use(cors());
  app.use((req,res, next ) =&gt; {
      res.setHeader(&quot;Access-Control-Allow-Origin&quot; ,&quot;*&quot;);
      res.setHeader( &quot;Access-Control-Allow-Origin&quot; ,&quot;*&quot;);
      next();
  });
  // DB Config
  const connection_url='mongodb+srv://whatsapp:asdfghjkl1233@cluster0.ngclm.mongodb.net/whatsapp?retryWrites=true&amp;w=majority';
  
  mongoose.connect(connection_url,{
      useCreateIndex: true,
      useNewUrlParser: true,
      useUnifedTopology: true
  })
  
  // ?????
  const db = mongoose.connection;
  
  db.once(&quot;open&quot;,()=&gt;{
      console.log(&quot;db connected&quot;);
      // message contents is from mongodb database
      const msgCollection = msgCollection('whatsapp'); //collection name in mongodb messagecontents
      // messagecontents changing to whatsapp
      const changeStream = msgCollection.watch();
      // Change Stream  function
      changeStream.on(&quot;change&quot;, (change) =&gt; 
      {
          // this is when we troggling pusher
          console.log('A changed is occur',change);
  
          if (change.operationType === 'insert'){
              const messageDetails = change.fullDocument;
              pusher.trigger('message', 'insert', {
                  name:messageDetails.user,
                  message: messageDetails.message,
                  timeStamp: messageDetails.timeStamp,
                  received: messageDetails.received
              });
          } else {
              console.log('Error Troggling pusher');
          }
      });
  });
  // api router
  app.get('/',(req,res) =&gt; {
      res.status(200).send(&quot;Hello World&quot;);
  });
  
  // api to get all the data from database
  app.get('/messages/sync' , (req,res) =&gt; {
  //    Messsages.find() to get back all the messages
     Messages.find((err,data) =&gt; {
          if (err) {
              res.status(500).send(err)
          }
           else {
               res.status(200).send(data)
           }
      });
  });
  
  
  app.post('/api/messages/new', (res,req) =&gt; {
      const dbMessage = req.body 
      message.create(dbMessage, (err,data)=&gt;{
          if (err){
              res.status(500).send(err)
          }
          else {
              res.status(201).send(`new number created: \n ${data}`)
          }
  
      });
  });
  // listen
  app.listen(port, () =&gt; console.log(`listen on local host ${port}`));
  </code></pre>
  <p>MY schema (dbMessages.js)</p>
  <pre><code>import mongoose from &quot;mongoose&quot;;
  
  const whatsappSchema = mongoose.Schema({
      message:String,
      name:String,
      timestamp:String
  });
  
  export default mongoose.model('whatsapp', whatsappSchema);
  </code></pre>
  <p>My Package.Json</p>
  <pre><code>{
    &quot;name&quot;: &quot;whatsapp-backend&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;discription&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;server.js&quot;,
    &quot;type&quot;: &quot;module&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
      &quot;start&quot;: &quot;node server.js&quot;,
      &quot;nodemon&quot;:&quot;nodemon --experimental-modules --es-module-specifier-resolution=node &quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;zain&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;cors&quot;: &quot;^2.8.5&quot;,
      &quot;express&quot;: &quot;^4.17.3&quot;,
      &quot;express_js&quot;: &quot;^1.0.0&quot;,
      &quot;mongoose&quot;: &quot;^6.2.5&quot;,
      &quot;nodemon&quot;: &quot;^2.0.15&quot;,
      &quot;pusher&quot;: &quot;^5.0.1&quot;,
      &quot;pusher-js&quot;: &quot;^7.0.6&quot;
    }
  }
  </code></pre>