Error connecting to db: server returned error on SASL authentication step: BSON field 'saslContinue.mechanism' is an unknown field

I am trying to connect to remote mongodb server from another server.

remote mongodb version: 5.0.8
remote mongodb tools version: 100.5.1

when I am trying to connect to the db using old mongodb driver then it throws following error:

server returned error on SASL authentication step: BSON field 'saslContinue.mechanism' is an unknown field.

connection function:

import (
	"gopkg.in/mgo.v2"
)

func ConnectDb() (mongoSession *mgo.Session) {
	mongoDBDialInfo := &mgo.DialInfo{
		Addrs:    []string{ThemeDatabaseIpPort},
		Username: ThemeDbUsername,
		Password: ThemeDbPassword,
		Database:  "admin",
		Timeout:   60 * time.Second,
		PoolLimit: 4096,
	}
	mongoSession, err := mgo.DialWithInfo(mongoDBDialInfo)
	if err != nil {
		fmt.Printf("CreateSessionForThemeDB: %s\n", err)
		defer mongoSession.Close()
		return mongoSession
	}
	mongoSession.SetMode(mgo.Monotonic, true)
	return mongoSession
}

It could be driver version compatibility issues
You may have to upgrade your driver

@Aman_Kaur the “gopkg.in/mgo.v2” package only officially supports up to MongoDB v3.6. To use MongoDB v5.0.8, you need to use the “go.mongodb.org/mongo-driver” package, which is the officially supported driver for Go.

Check out the Go driver compatibility matrix here to see what Go driver versions support what MongoDB server versions.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.