To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-go-driver/7d368216-0b39-4e67-ad47-3f0e7fa629ff%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "mongodb-go-driver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-go-driver+unsubscribe@googlegroups.com.
To post to this group, send email to mongodb-go-driver@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-go-dri...@googlegroups.com.
To post to this group, send email to mongodb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-go-driver/694b1298-eec1-4090-ba2c-6a072ba7c93c%40googlegroups.com.
The address I used in the Golang client on the guest was 10.0.2.2. However, Mongo seemed to suggest instead to use the primary address 127.0.0.1. That of course didn't work from the VirtualBox guest, and collection.Find failed. I got it working by adding clientopt.Single(true).
What import statement did you run for the clientopt.Single(true) command?
Hi,
The original question was posted in July 2018 (alpha v0.0.10). There has been a lot of changes to mongo-go-driver since, currently it’s beta version v0.1. In the current version (v0.1), the import would be github.com/mongodb/mongo-go-driver/mongo/options. See also mongo/options/clientoptions.go#L248-L259
That of course didn’t work from the VirtualBox guest, and collection.Find failed. I got it working by adding clientopt.Single(true).
Worth mentioning that the original thread solved the problem by connecting to a single member of the replica set in a standalone mode. The problem was the replica set configurations contains host names that are not recognisable from the VirtualBox, hence connecting directly to only one member (without discovery of the other members via the config) works.
Although the error message may be similar to yours, it may be a completely different issue. Depending on the use case, you may want to solve it differently as well (i.e. connecting to a single member of replica set does not provide high availability).
If you still have issues, I would recommend to open a new thread along with:
Regards,
Wan.