title: Not able to use mongodb transactions using mongo go driver
body: <p>I have created a mongodb replica set. I am able to run transactions from the mongo shell. But when I try to do it using mongo-go-driver I always get this error <code>(IllegalOperation) Transaction numbers are only allowed on a replica set member or mongos</code>. I am not sure where I am going wrong. I am using this as a reference <code>https://github.com/simagix/mongo-go-examples/blob/master/examples/transaction_test.go</code>. </p>
  
  <p>I create the client like this </p>
  
  <pre class="lang-golang prettyprint-override"><code>client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017,localhost:27018,localhost:27019?replicaSet=rs"))
  </code></pre>
  
  <p>I can connect to the individual mongodb instances, just not the replica set.
  This is the transaction that I am trying to run</p>
  
  <pre class="lang-golang prettyprint-override"><code>var session mongo.Session
  
  coll := db.Collection("collectionname")
  
  if session, err = client.StartSession(); err != nil {
      return "", fmt.Errorf("Could not start session: %q", err)
  }
  
  if err = session.StartTransaction(); err != nil {
      return "", fmt.Errorf("Could not start Transaction: %q", err)
  }
  
  if err = mongo.WithSession(ctx, session, func(sc md.SessionContext) error {
  
      newVal, err = coll.InsertOne(sc, val) // some val that I have
      if err != nil {
          sc.AbortTransaction(sc)
          return fmt.Errorf("Error during New address creation, aborting: %q", err)
      }
  
      if err = sc.CommitTransaction(sc); err != nil {
          return fmt.Errorf("Error While commiting New address Transaction: %q", err)
      }
      return nil
  }); err != nil {
      return "", err
  }
  
  session.EndSession(ctx)
  </code></pre>
  
  <p>Is there something I am missing. Is there some other example maybe that I can reference. Thanks for the help/suggestions.</p>