Closed csreddyennam closed 5 years ago
Hi @csreddyennam I don't see Table sdk is used in your example, and I don't think Table sdk alllow passing in HttpClientHandler. What is your scenario using table and can not connect to cosmos? Could you elaborate more?
Thanks,
Hi Donghexu,
I am unable to connect to CosmoDB from behind the proxy, when you run the above sample program you can see the issue.
Please see the below error message: ["One or more errors occurred. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)",
Hi @csreddyennam Could you tell us you are using Table API or SQL API? From your sample I don't see Table scenarios.
Hi Donghexu, Initially client connect itself failing, it fails at DocumentClient open connection.
Hi @csreddyennam, could you please let us know if you are experiencing issue with Cosmos Table SDK or not? From your example you are using the SQL SDK which unfortunately we can not provide deeper help. If you have scenarios with Table SDK, please let us know the details. Thank you,
the above issue got resolved by replacing the clientHandler as below and connection mode with GateWay.
var clientHandler = new System.Net.Http.HttpClientHandler() { Proxy = new System.Net.WebProxy("http://XXXXXX", false), PreAuthenticate = true, UseDefaultCredentials = false, UseProxy = true, };
connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Https, RetryOptions = new RetryOptions() { MaxRetryAttemptsOnThrottledRequests = DefaultRetryCount, MaxRetryWaitTimeInSeconds = DefaultRetryInterval } };
Describe the bug When we connect o DocumentDB, unable to open connection to cosmoDB. The same work when we have .Net Core 2.0 Below are the version we are using: .Net Core 2.2 Package used: Visual studion: 2017 (15.9.12)
Exception or Stack Trace InnerException = {System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Http.Connec...
["One or more errors occurred. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)"," at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n at System.Threading.Tasks.Task.Wait()\r\n at webapi.Controllers.ValuesController.Get() in C:\XXXi\ConsoleApp1\webapi\Controllers\ValuesController.cs:line 42 System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond\r\n at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\r\n --- End of inner exception stack trace ---\r\n at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\r\n at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask)\r\n at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at Microsoft.Azure.Documents.Client.DocumentClient.HttpRequestMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)\r\n at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.GetDatabaseAccountAsync(Uri serviceEndpoint)\r\n at Microsoft.Azure.Documents.Routing.GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(Uri defaultEndpoint, IList1 locations, Func`2 getDatabaseAccountFn)\r\n at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.InitializeReaderAsync()\r\n at Microsoft.Azure.Documents.Client.DocumentClient.InitializeGatewayConfigurationReader()\r\n at Microsoft.Azure.Documents.Client.DocumentClient.GetInitializationTask(IStoreClientFactory storeClientFactory)\r\n at Microsoft.Azure.Documents.Client.DocumentClient.EnsureValidClientAsync()\r\n at Microsoft.Azure.Documents.Client.DocumentClient.OpenPrivateInlineAsync(CancellationToken cancellationToken)"]
To Reproduce Open a console application of .Net Core 2.2 with package:
Code Snippet try {
Expected behavior Connection to DocumentDB (CosmoDB) should open with out error.
Setup (please complete the following information):
OS: Windows IDE : Visual studion 2017 (15.9.12) Version of the Library Microsoft.Azure.DocumentDB.Core=> Version="2.4.0" Additional context Its working with .Net Core 2.0