cosmosdb-server icon indicating copy to clipboard operation
cosmosdb-server copied to clipboard

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

Open lonewarrior556 opened this issue 5 years ago • 3 comments

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?

lonewarrior556 avatar Apr 15 '20 13:04 lonewarrior556

@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.

southpolesteve avatar Apr 15 '20 16:04 southpolesteve

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

lonewarrior556 avatar Apr 15 '20 16:04 lonewarrior556

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

Socolin avatar Dec 25 '20 20:12 Socolin