Go couldn't connect mongodb 2.4 version

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Do
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I couln't connect mongodb with golang.

      telnet mongoHost 27017 it is okey

      ping mongoHost it is okey

      MongoHost is my private host not docker

      Mongodb version : 2.4.3

      MongoDriver: 1.3.2

      Go version: go version go1.14.1 darwin/amd64

      Operation System: Mac

      Here is my connection code

       

      
      clientOptions := &options.ClientOptions{}
      clientOptions.SetServerSelectionTimeout(4 * time.Second)
      clientOptions.SetDirect(true)
      clientOptions.SetAppName("tests")
      clientOptions.SetHosts([]string{"mongoHost:27017"})
      clientOptions.SetReadPreference(readpref.Secondary())
      client, err := mongo.NewClient(clientOptions)
      if err != nil {
          log.Fatal(err)
      }
      ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
      err = client.Connect(ctx)
      if err != nil {
          log.Fatal(err)
      } 

       

      I changed timeout but It doesn't changed connection every time I got this error:

      2020/04/12 14:06:19 server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: mongoHost:27017, Type: Standalone, State: Connected, Average RTT: 13849652 }, ] }
       

            Assignee:
            Unassigned
            Reporter:
            erol yap?c?
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: