vercel / cosmosdb-server

A Cosmos DB server implementation for testing your applications locally.
MIT License
171 stars 30 forks source link

Query to //addresses/?$resolveFor=dbs&$filter=protocol%20eq%20rntbd #29

Open lonewarrior556 opened 4 years ago

lonewarrior556 commented 4 years ago

The code Lib I am using makes a query to //addresses/?$resolveFor=dbs&$filter=protocol%20eq%20rntbd when it launches..

it expects Json looking like this:

{
"Addresss":[
{
"isPrimary":true,
"physcialUri":"rntbd://foo.documents.azure.com:11018/apps/16d6d56e-e73d-4069-98f5-2e677328a7d1/services/ce59e2ac-eac5-490f-9262-585b250f0399/partitions/2fe30e96-a74a-4596-a674-2c04a39c8603/replicas/132312777763206824p/",
"protocol":"rntbd",
"partitionKeyRangeId":"M",
"partitionIndex":"0@0"
},
{
"isPrimary":false,
"physcialUri":"rntbd://foo.documents.azure.com:11316/apps/16d6d56e-e73d-4069-98f5-2e677328a7d1/services/ce59e2ac-eac5-490f-9262-585b250f0399/partitions/2fe30e96-a74a-4596-a674-2c04a39c8603/replicas/132312759686602427s/",
"protocol":"rntbd",
"partitionKeyRangeId":"M",
"partitionIndex":"0@0"
},
{
"isPrimary":false,
"physcialUri":"rntbd://foo.documents.azure.com:11011/apps/16d6d56e-e73d-4069-98f5-2e677328a7d1/services/ce59e2ac-eac5-490f-9262-585b250f0399/partitions/2fe30e96-a74a-4596-a674-2c04a39c8603/replicas/132312759686602428s/",
"protocol":"rntbd",
"partitionKeyRangeId":"M",
"partitionIndex":"0@0"
},
{
"isPrimary":false,
"physcialUri":"rntbd://foo.documents.azure.com:11009/apps/16d6d56e-e73d-4069-98f5-2e677328a7d1/services/ce59e2ac-eac5-490f-9262-585b250f0399/partitions/2fe30e96-a74a-4596-a674-2c04a39c8603/replicas/132312804907485886s/",
"protocol":"rntbd",
"partitionKeyRangeId":"M",
"partitionIndex":"0@0"
}
],
"_count":4
}

without the $filter=protocol%20eq%20rntbd it includes https ie

{"isPrimary":true,
  "physcialUri":"https://foo.documents.azure.com:11618/apps/16d6d56e-e73d-4069-98f5-2e677328a7d1/services/ce59e2ac-eac5-490f-9262-585b250f0399/partitions/2fe30e96-a74a-4596-a674-2c04a39c8603/replicas/132312777763206824p//",
  "protocol":"https",
  "partitionKeyRangeId":"M",
  "partitionIndex":"0@0"}

first of all wth is rntbd protocol, can it be mocked?

But the issue is that with out //addresses/blah returning anything, The Lib crashes parsing non existent json. Can this be added to routes?

southpolesteve commented 4 years ago

@lonewarrior556 Cosmos JavaScript SDK developer here. Which SDK are you using to talk to Cosmos? Can you force it to use gateway mode? That may solve this issue.

RNTB is the custom TCP protocol used by Cosmos direct mode. It is only used in the .NET and Java SDKs when in "direct" mode. JavaScript and Python talk to the cosmos HTTP rest API which the cosmos-server project is meant to simulate.

lonewarrior556 commented 4 years ago

Hey @southpolesteve yea lib is in .net It's prebuilt so I can't change much except for the endpoint using an env variable.

In the absence of a linux docker cosmodb emulator I've resorted to using this, which (when I hack it to return something for that endpoint seems to work after some delay.. perhaps it times out and connect thru https?)

Thanks to whoever posted that as a possibility here: https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/17

Socolin commented 3 years ago

Hello, I encounter this error but this seems related with the DirectoConnectionMode https://docs.microsoft.com/en-us/azure/cosmos-db/sql-sdk-connection-modes

It seems to work when specifying explicitly .WithConnectionModeGateway() instead of WithConnectionModeDirect() on CosmosClientBuilder