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

Cannot connect to local server using hostname 'localhost', only IP '127.0.0.1'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None
    • Environment:
      FreeBSD 11.1, Mono 5.2, MongoDB 3.4.4

      Description

      I have a default configuration of MongoDB 3.4.4 (installed from pkg) on FreeBSD. I can connect fine with the CLI (using 'localhost' or '127.0.0.1') or from my .NET/C# program (only using the IP 127.0.0.1), but connecting using 'localhost' from within my program is timing out with the following error:

      System.TimeoutException:  A timeout occured after 10000ms selecting a server using CompositeServerSelector{
           Selectors = WritableServerSelector,
           LatencyLimitingServerSelector{
               AllowedLatencyRange = 00: 00: 00.0150000 
          } 
      }. Client view of cluster state is {
           ClusterId :  \"1\",
           ConnectionMode :  \"Automatic\",
           Type :  \"Unknown\",
           State :  \"Disconnected\",
           Servers :  [
              {
                   ServerId:  \"{
                       ClusterId :  1,
                       EndPoint :  \"Unspecified/localhost: 27017\" 
                  }\",
                   EndPoint:  \"Unspecified/localhost: 27017\",
                   State:  \"Disconnected\",
                   Type:  \"Unknown\" 
              }
          ] 
      }.\n  at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector,
       MongoDB.Driver.Core.Clusters.ClusterDescription description) [
          0x00013
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.Core.Clusters.Cluster+WaitForDescriptionChangedHelper.HandleCompletedTask (System.Threading.Tasks.Task completedTask) [
          0x00009
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector,
       MongoDB.Driver.Core.Clusters.ClusterDescription description,
       System.Threading.Tasks.Task descriptionChangedTask,
       System.TimeSpan timeout,
       System.Threading.CancellationToken cancellationToken) [
          0x00021
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.Core.Clusters.Cluster.SelectServer (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector,
       System.Threading.CancellationToken cancellationToken) [
          0x00057
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.Core.Bindings.WritableServerBinding.GetWriteChannelSource (System.Threading.CancellationToken cancellationToken) [
          0x00011
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.Execute (MongoDB.Driver.Core.Bindings.IWriteBinding binding,
       System.Threading.CancellationToken cancellationToken) [
          0x00006
      ] in <295d3f442b614d5d817f23ef80ed36dc>: 0 \n  at MongoDB.Driver.OperationExecutor.ExecuteWriteOperation[
          TResult
      ] (MongoDB.Driver.Core.Bindings.IWriteBinding binding,
       MongoDB.Driver.Core.Operations.IWriteOperation`1[
          TResult
      ] operation,
       System.Threading.CancellationToken cancellationToken) [
          0x00000
      ] in : 0 \n  at MongoDB.Driver.MongoCollectionImpl`1[
          TDocument
      ].ExecuteWriteOperation[
          TResult
      ] (MongoDB.Driver.Core.Operations.IWriteOperation`1[
          TResult
      ] operation,
       System.Threading.CancellationToken cancellationToken) [
          0x0000c
      ] in : 0 \n  at MongoDB.Driver.MongoCollectionImpl`1[
          TDocument
      ].BulkWrite (System.Collections.Generic.IEnumerable`1[
          T
      ] requests,
       MongoDB.Driver.BulkWriteOptions options,
       System.Threading.CancellationToken cancellationToken) [
          0x00039
      ] in : 0 \n  at MongoDB.Driver.MongoCollectionBase`1[
          TDocument
      ].InsertOne (TDocument document,
       MongoDB.Driver.InsertOneOptions options,
       System.Threading.CancellationToken cancellationToken) [
          0x00030
      ] in : 0 \n  at Iinu.Server.Database.DatabaseClient.AddKitchen (Iinu.Server.Database.Kitchen kitchen) [
          0x00007
      ] in <47651e00c1fc448c853303d65a8c12a6>: 0 \n  at Iinu.Server.Registration.KitchenRegistrationService.Register (Iinu.Server.Api.Data.Kitchen kitchen,
       MongoDB.Bson.ObjectId& kitchenId) [
          0x00020
      ] in <47651e00c1fc448c853303d65a8c12a6>: 0 \n  at Iinu.Server.Api.IdentityModule.b__2_2 (System.Object parameters) [
          0x00008
      ] in <47651e00c1fc448c853303d65a8c12a6>: 0 \n  at (wrapper dynamic-method) System.Object: CallSite.Target (System.Runtime.CompilerServices.Closure,
      System.Runtime.CompilerServices.CallSite,
      System.Func`2,
      object)\n  at System.Dynamic.UpdateDelegates.UpdateAndExecute2[
          T0,
          T1,
          TRet
      ] (System.Runtime.CompilerServices.CallSite site,
       T0 arg0,
       T1 arg1) [
          0x0010f
      ] in : 0 \n  at Nancy.Routing.Route+<>c__DisplayClass4.b__3 (System.Object parameters,
       System.Threading.CancellationToken context) [
          0x00049
      ] in : 0
      

      This distinctly seems like a bug to me, either in MongoDB or Mono.

        Attachments

          Activity

            People

            Assignee:
            rstam Robert Stam
            Reporter:
            alexreg Alexander Regueiro
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: