Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3126

[Cosmos DB] Current beta breaks connection on linux hosts

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.11.0-beta1
    • Component/s: None
    • None
    • Environment:
      Linux, .netcore 3.1 and .net 5

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            manuel.gysin@gmail.com Manuel Gysin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: