DEV Community

Jackson Kasi
Jackson Kasi Subscriber

Posted on

3

How to fix MongoDB connection Error in AWS Lambda?

Hello developers!

Hey, does Anyone face a MongoDB connection error/issue on AWS lambda?
and if you know the solution, please help me, guys!

my code works perfectly in my local system!

But when I try to post, using the API gateway endpoint, MongoDB disconnect! ( session time-out error )

Tech things πŸ› οΈ:

  • aws lambda
  • aws api gateways
  • serverless
  • node js [16.x]
  • azure cosmos DB ( MongoDB )

Image description

Image description

Top comments (1)

Collapse
 
jacksonkasi profile image
Jackson Kasi β€’ β€’ Edited

guys, I got it!

db.js -> way 1

Image description

db.js -> way 2

Image description

index.js

Image description

credits goes to: brnaba
stackoverflow.com/users/19408037/b...

refer this!

stackoverflow.com/questions/743141...

Image of Docusign

πŸ› οΈ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️