Foobar
Foobar

Reputation: 931

Connection from Go Application to MongoDB Is Not Persisting

I'm connecting a Go application to MongoDB using the following code:

session, sessionErr := mgo.Dial("127.0.0.1:27017")

The connection is established but doesn't persist as indicated in mongo.log. The following 3 log lines repeat themselves in the log file:

{"t":{"$date":"2022-11-03T19:24:55.375-04:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:50318","uuid":"75c727df-dc34-4dfd-a666-50aba1659695","connectionId":146,"connectionCount":3}}
{"t":{"$date":"2022-11-03T19:24:55.381-04:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn146","msg":"client metadata","attr":{"remote":"127.0.0.1:50318","client":"conn146","doc":{"os":{"type":"linux","architecture":"arm64"},"driver":{"name":"mgo","version":"globalsign"}}}}
{"t":{"$date":"2022-11-03T19:24:55.381-04:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn146","msg":"Connection ended","attr":{"remote":"127.0.0.1:50318","uuid":"75c727df-dc34-4dfd-a666-50aba1659695","connectionId":146,"connectionCount":2}}

Both the Go application and MongoDB are running on localhost on macOS Monterey. What could be the reason for this? Any help would be greatly appreciated. Thanks.

Upvotes: 1

Views: 181

Answers (0)

Related Questions