I am using .NET SDK Microsoft.Azure.DocumentDB
to work with cosmos db on Azure.
I've a problem when my network cannot connect to cosmos db (proxy, network, ...)
Example:
this.client = new DocumentClient(new Uri(EndpointUrl), PrimaryKey, new ConnectionPolicy {
ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp,
RetryOptions = new RetryOptions {MaxRetryAttemptsOnThrottledRequests = 5,
MaxRetryWaitTimeInSeconds= 5 },
RequestTimeout = new TimeSpan(1000)});
var a = await this.client.CreateDatabaseIfNotExistsAsync(new Database { Id = "FamilyDB" });
My application loop forever in line CreateDatabaseIfNotExistsAsync
and with message:
Endpoint not reachable. Refresh cache and retry
Failover happening. retryCount 6
RefreshLocationAsync() refreshing locations
An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
Endpoint not reachable. Refresh cache and retry
Failover happening. retryCount 7
RefreshLocationAsync() refreshing locations
An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
....
I cannot stop or try catch it, I tried requestoption
, requestTimeout
but it is not working.
So if I cannot connect to cosmos db, how can i stop it or try catch it.