This question was originally asked by ben-graffle on Github.
I'm posting here to widen the audience for this question.
Receiving 408 timeouts with the cosmos C# SDK with specific port mapping configurations in a docker-compose file
docker compose that works
cosmos:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
container_name: cosmos
ports:
- 8081:8081
- 10251:10251
- 10252:10252
- 10253:10253
- 10254:10254
expose:
- "8081"
- "10251-10255"
environment:
- AZURE_COSMOS_EMULATOR_PARTITION_COUNT=6
- AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=false
- AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=${LOCALIPADDRESS}
docker compose that does not work
cosmos:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
container_name: cosmos
expose:
- "8081"
- "10251-10255"
ports:
- 8082:8081
- 10252:10251
- 10253:10252
- 10254:10253
- 10255:10254
environment:
- AZURE_COSMOS_EMULATOR_PARTITION_COUNT=6
- AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=false
- AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=${LOCALIPADDRESS}
Function call that throws exception
var httpMessageHandler = new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
HttpClientFactory = () => new HttpClient(httpMessageHandler),
ConnectionMode = ConnectionMode.Gateway,
Serializer = new CosmosJsonNetCustomSerializer(),
RequestTimeout = TimeSpan.FromMinutes(3)
};
using CosmosClient client = new CosmosClient(cosmosEndpoint, COMSOS_KEY, cosmosClientOptions);
var db = await client.CreateDatabaseIfNotExistsAsync("GraffleMinerDatabase", 4000, null, CancellationToken.None);
The first docker-compose yaml works and the second does not. Receiving the following error
Unhandled exception. Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: RequestTimeout (408); Substatus: 0; ActivityId: 2f24681b-db18-44aa-afc8-e12ba02d8930; Reason: (GatewayStoreClient Request Timeout. Start Time UTC:03/29/2022 22:28:56; Total Duration:36015.4719 Ms; Request Timeout 20000 Ms; Http Client Timeout:180000 Ms; Activity id: 2f24681b-db18-44aa-afc8-e12ba02d8930;);
The reason I am looking to map the ports differently is i need to have two cosmos emulator docker containers running simultaneously.
Any assistance/insight would be greatly appreciated.