SDK hangs when server is unreachable
See original GitHub issueDescribe the bug I am using v3.9.1 and testing this against a local emulator.
I wanted to test how our code behaves in face of network partitions. Therefore, I reproduced a situation where the client is successfully initialized but before executing a transactional batch, the server is shut down. The result is that ExecuteAsync
hangs.
To Reproduce
async Task Main()
{
var connectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=<account key>";
var clientBuilder = new CosmosClientBuilder(connectionString);
var clientWithSerialization = clientBuilder.WithSerializerOptions(new CosmosSerializationOptions
{
PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
});
var containerProperties = new ContainerProperties
{
Id = "testcontainer",
PartitionKeyPath = $"/partitionKey"
};
var client = clientWithSerialization.Build();
var database = (await client.CreateDatabaseIfNotExistsAsync("test")).Database;
var container = (await database.CreateContainerIfNotExistsAsync(containerProperties)).Container;
var item = new Item
{
PartitionKey = "abc"
};
var batch = container.CreateTransactionalBatch(new PartitionKey(item.PartitionKey));
batch.CreateItem(item);
// Put a breakpoint here and before continuing, shut the server down
var response = await batch.ExecuteAsync();
}
Expected behavior
ExecuteAsync
returnsTransactionalBatchResponse
where an error response status is indicated- or an exception is thrown
Actual behavior
ExecuteAsync
never finishes.
Environment summary SDK Version: 3.9.1 OS Version: Windows
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
git - Why do I always get the error message "Server is ...
I tried to change the url of github but i can't. I already tried to connect via Tokens but that doesn't work either....
Read more >bash - Make SSH time out quicker when trying to access ...
It hangs because it waits for your ssh to timeout, it would probably run through if you wait long enough or add a...
Read more >Crash when initializing SDK with unreachable server
I'm having crashes when trying to initialize the SDK while the server was unreachable - in my case it was because I was...
Read more >Server unreachable, best way to find out the cause?
During this downtime, the crontabs etc. are running normally and I couldn't find any clou of a crash or related in any logfiles....
Read more >35996 - 12.1 EDK - SDK "download operation timed out" error
When I download my software application for debugging, the following error message occurs: "download operation timed out." What can I do to work ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the explanation @ealsur, makes sense.
Using gateway mode did not help.
It reproduces in a 4.7.2 console application: https://github.com/skurik/cosmos-hang