Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-674

server selection timeout error when connecting to replica set

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 0.0.18
    • Connections
    • None
    • 2 mongodb with docker (replica set configured successfully, shell connection works fine)
      macOS 10.14.1
      go 1.11.2 with go module

    Description

      ctx := context.Background()
       
      clientOptions := &options.ClientOptions{}
      clientOptions.SetHosts([]string\{"mongodb://localhost:27017", "mongodb://localhost:27018"})
      clientOptions.SetReadPreference(readpref.Primary())
      clientOptions.SetServerSelectionTimeout(time.Duration(2*time.Second))
       
      client, err := mongo.NewClientWithOptions("mongodb://localhost:27017,localhost:27018", clientOptions)
      if err != nil {
       panic(err)
      }
       
      err = client.Connect(ctx)
      if err != nil {
       panic(err)
      }
       
      dbs, err := client.ListDatabaseNames(ctx, bson.D{})
      if err != nil {
       panic(err)
      }
       
      fmt.Println(dbs)
      

      but result is: panic: server selection timeout
      I also added replicaSet=rs0 option but result was same.
      Does this driver not yet support replica set?

      Attachments

        Activity

          People

            Unassigned Unassigned
            issacs98@gmail.com 성욱 조
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: