[CSHARP-3126] [Cosmos DB] Current beta breaks connection on linux hosts Created: 07/Jun/20  Updated: 08/Jun/20  Resolved: 08/Jun/20

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 2.11.0-beta1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Manuel Gysin Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux, .netcore 3.1 and .net 5


Issue Links:
Duplicate
duplicates CSHARP-3117 Fix timeout connecting to server on L... Closed

 Description   

The current beta breaks Cosmos DB connections when under a linux host system, windows hosts are not affected. Downgrading to current stable version fixes the problem.

string connectionString = @"mongodb://aaa:bbb@ccc.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@ddd@"; 
 
MongoClientSettings settings = MongoClientSettings.FromUrl( new MongoUrl(connectionString) ); 
settings.SslSettings = new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 }; 
var mongoClient = new MongoClient(settings);

 
{{fail: Microsoft.AspNetCore.Server.Kestrel[13]Connection id "0HM09JMTH8P61", Request id "0HM09JMTH8P61:00000004": An unhandled exception was thrown by the application.System.TimeoutException: 
A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. 
Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ 
ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/aaa.mongo.cosmos.azure.com:10255" }", EndPoint: "Unspecified/aaa.mongo.cosmos.azure.com:10255", ReasonChanged: "Heartbeat", State: "Disconnected", 
Type: "Unknown", 
HeartbeatException: "MongoDB.Driver.MongoConnectionException: 
An exception occurred while opening a connection to the server.
 ---> 
System.PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt.
   at System.Net.Sockets.Socket.ThrowMultiConnectNotSupported()
   at System.Net.Sockets.Socket.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state)
   at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(Socket socket, EndPoint endPoint, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Connections.SslStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2020-06-05T22:14:26.2687880Z", LastUpdateTimestamp: "2020-06-05T22:14:26.2687882Z" }] }.   
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)  
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)  
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)   
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)   
at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)  
 at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)   
at MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken)   
at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)  
 at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)   
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
   at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken cancellationToken)  
 at MongoDB.Driver.IAsyncCursorSourceExtensions.ToList[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
   at backend.Services.UserService.Get() in /home/vsts/work/1/s/backend/Services/UserService.cs:line 41
   at backend.Controllers.UsersController.Get() in /home/vsts/work/1/s/backend/Controllers/UserController.cs:line 36
   at lambda_method2(Closure , Object , Object[] )
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequest[TContext](IHttpApplication`1 application)}}

 

Reference: https://stackoverflow.com/questions/62225159/cosmos-db-net-throws-error-when-trying-to-connect-from-linux-docker-container



 Comments   
Comment by Esha Bhargava [ 08/Jun/20 ]

Thanks for the report. This looks like a dup of CSHARP-3117. Please follow that ticket.

Comment by Manuel Gysin [ 07/Jun/20 ]

Sorry, the format broke while posting. I can't edit it.

Generated at Wed Feb 07 21:44:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.