Calling to graph db from aps.net core web api causes exception #1064
Replies: 1 comment
-
For those who have the same problem:
'CosmosDb' is used by .UseCosmosDb() extension.
The reasons of the exception was linked with connections to db (in the web sockets infrastructure). Since I had multiple instances of IGremlinQuerySource, some connection pool issue happened. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, thank you for your time and effort building this great library!
I'm working on asp.net core web api, I use net core 6.0 together with exram.gremlinq (10.0.0) to interact with Azure Cosmos DB.
I wrote a service, which is a wrapper on top of IGremlinQuerySource. The instance of service is declared as singleton in web api DI. Service is resolved in api controllers or other services, where I need access to cosmos db.
I get the following exception: "One or more errors occurred. (The server returned status code '404' when status code '101' was expected.)". Stack doesn't contain anything useful. The main problem is the exception happens unpredictably and not all the time. I didn't see any possible reason why it happens.
It happens when I run several tests. Tests are executed locally, so web api is hosted on locahost, and web api calls to azure cosmos db - gremlin. Sometimes all tests pass and all is good, and sometimes they fail with that exception.
The only explanation is - the IGremlinQuerySource object possibly loses the connection (or connection becomes stale) and the connection should be reset or so. And maybe singleton DI declaration does not fit for the web api type of apps. Maybe there are some disposable internal objects which i'm not aware of and I need to take care about them in a certain way...
Please advise.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions