I'm using official MongoDB Go driver (go.mongodb.org/mongo-driver/mongo
).
As ConnectString I use mongodb://localhost:12345/test?maxidletimems=100000000000
.
Sample of connection code:
clientOptions := options.Client().ApplyURI(ConnectString)
client, err = mongo.Connect(context.Background(), clientOptions)
After some time (about 12 hours) driver reset connection(I think that driver do it, because mongodb not write any logs besides "client disconnect").
And I don't check connection(use Ping or something else), just trying to write. Sample:
coll := client.Database(DatabaseName).Collection(CollectionName)
_, err = coll.InsertOne(context.Background(), item)
This returns error "driver: bad connection"
.
After connection I write some items to db, so collection and other things exists.
I pass
maxidletimems
~= 3 years, but connection dies.
What happen? How to keep connection alive?
My bad, it was message from another database. Named Clickhouse. Thank to all of you guys