Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

Getting "'crypto' module: error signing message" when attempting to send a message via a MongoDB server function

$
0
0

I am attempting to setup a trigger in my MongoDB cluster, that, when an object is updated, pushes out a notification to certain users. I have firebase-admin initialized properly, but am running into issues when I attempt to send the message.

I have firebase-admin and crypto-js installed as explicit dependencies. I have been loosely following this tutorial, so if you need additional context, I'd recommend reading that, as it captures my situation well.

MongoDB Function

This is the code in the mongoDB function. I am pretty new to it, so I'm sorry if there are a lot of syntax / style issues. I am using the editor in the 'create/edit Function' page on my MongoDB dashboard

exports = async function(changeEvent) {  const admin = require('firebase-admin'); admin.initializeApp({     credential: admin.credential.cert({     projectId: context.values.get('projectId'),     clientEmail: context.values.get('clientEmail'),     privateKey: context.values.get('FireBase-Admin-Private-Key').replace(/\\n/g, '\n'),   }), }); const topic = 'PostNotification'; const message = {topic}; if (changeEvent.operationType === 'insert') {   const name = "Test Notification!"   message.notification = {     body: `${name} has been added to the list`,     title: 'This is a great notification'   }; } else if (changeEvent.operationType === 'update') {   const name = "Test Notification!"   message.notification = {     body: `${name} has been added to the list`,     title: 'This is a great notification'   }; } admin.messaging().send(message)   .then((response) => {     // Response is a message ID string.     console.log('Successfully sent message:', response);     return true;   })   .catch((error) => {     console.log('Error sending message:', error);     return false; });};

Firebase admin v12.x.x

When I had the latest version of the Firebase-admin package installed (not specifying any specific version), I got the following output:

Error sending Message: TypeError: Value is not an object: undefined

There was a lot of discussion online about this issue, with most people saying that downgrading to v11.0.1 or v10.0.0 solved the issue for them. You can check out the full conversation here

Firebase admin v11.0.1 & v10.0.0

After downgrading the error I got changed slightly to

Error sending message: 'crypto' module: error signing message

Looking this up yielded much less results and after a days bit of research, I'm pretty lost.

If anyone knows of a work around to this issue, or can identify a simple mistake I've made, that would be great. Thanks


Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>