Azure Cosmos DB Connection issue in Node.js with mongoose module

Sohyeon Cho (DHL KR) 36 Reputation points
2022-12-22T08:30:02.047+00:00

I am trying to connect to Azure Cosmos DB using the mongoose module in Node.js.

Try mongoose.connect by declaring the URI in the env configuration file (nodemon.json to be exact).

======== app.js ========
...
mongoose.connect(process.env.MONGODB_URI, options
);

=====================

At this time, the following error occurs.
I would like to use the mongoose module whenever possible.
How to solve the MAC signature problem?

========= error =========
MongoServerError: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 1028;
ActivityId: 1609699a-f661-4884-aa15-eab65d52ce56; Reason: (Message: {"Errors":["The MAC
signature found in the HTTP request is not the same as the computed signature.
Server used following string to sign - 'post\ncolls\n\nthu, 22 dec 2022 05:42:50 gmt\n\n'.
Learn more: https://aka.ms/cosmosdb-tsg-mac-signature","Your account is currently configured with a total throughput limit of 1000 RU/s.
This operation failed because it would have increased the total throughput to 1400 RU/s. See https://aka.ms/cosmos-tp-limit for more information."]}
ActivityId: 1609699a-f661-4884-aa15-eab65d52ce56,
Request URI: /apps/8f912fc7-f1c2-460e-9795-2a1371811e40/services/f6923d3f-97d3-4380-9ad4-1fe34a73d9c3/partitions/e6b83650-e035-4d5f-a5f2-7040dad4c83f/replicas/133085019068788391p,
RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum,
Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0);

====================

Thanks in advance for your attention and answers.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,915 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sohyeon Cho (DHL KR) 36 Reputation points
    2022-12-23T03:57:36.86+00:00

    This problem has been solved and I share it for others.

    In fact, this message doesn't seem to help in determining the cause.

    The reason I got this message was that I didn't specify the DBNAME when connecting to MongoDB.
    Another case this error message was Not entering the correct password when connecting to MongoDB.

    If anyone has received this error message, please check the settings for connecting to MongoDB.

    2 people found this answer helpful.

  2. SSingh-MSFT 16,371 Reputation points Moderator
    2022-12-22T09:51:53.927+00:00

    Hi @Sohyeon Cho (DHL KR) ,

    Welcome to Microsoft Q&A platform and for using Azure services.

    Could you please check the Mongoose version in use.

    Azure Cosmos DB for MongoDB is compatible with up to version 5.13.15 of Mongoose. For more information, please see the issue discussion in the Mongoose GitHub repository.

    Also, please try to enhance throughput as the error message suggests.

    Other helpful links on this Error : The MAC signature found in the HTTP request 'XXXX' is not the same as computed signature and the-mac-signature-found-in-the-http-request-is-not-the-same-as-any-compute

    Hope this should help.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.