Does Faction support mongodb+srv ?
Hi,
I'm trying to deploy a Faction instance using a Mongo Atlas DB, but without success (Unknown Host exception). Does Faction support mongodb+srv in FACTION_MONGO_HOST ? srv connection format
Hey @sebastienbaillet, I have not tested with this scenario....But it should work. There are other Environment variables you can try like setting the port manually: FACTION_MONGO_PORT=27018
You probably won't need this next one but if the other does not work, you can try forcing an encrypted connection: FACTION_MONGO_SSL=true
If neither of these work, then I'll try to recreate it.
I set the following env:
FACTION_MONGO_HOST=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud
This is the mongodb+srv url given by my provider.
I get the following logs:
Caused by: org.hibernate.HibernateException: OGM001214: Unable to connect to MongoDB instance: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud}, caused by {java.net.UnknownHostException: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud}}]
It seems that Faction is simply trying to connect to the given url, and that can't work due to mongodb+srv behaviour. If you try to resolve the domain, you don't have CNAME or A record:
$ nslookup xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud
Server: 172.24.96.1
Address: 172.24.96.1#53
Non-authoritative answer:
*** Can't find xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mgdb.fr-par.scw.cloud: No answer
The client should resolve TXT and SRV record type to find the real ips of the database(s). srv-connection-format
There is something strange if I try one to set one of the instance real ip:
FACTION_MONGO_HOST=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.mgdb.fr-par.scw.cloud
# OR
FACTION_MONGO_HOST=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.mgdb.fr-par.scw.cloud.
I get the following error log:
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@2032c406. Client view of cluster state is {type=REPLICA_SET, servers=[{address=rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local}, caused by {java.net.UnknownHostException: rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local}}]
In this case, the url in the error seems to indicate that Faction is partially handling mongodb+srv. (I'm deploying faction in a Kubernetes cluster)
I check the mongo driver and I see that Faction is using mongo-java-driver which is deprecated, and the version is almost 3 years old. The new driver is mongodb-driver-sync. Could this be related to the old driver ?
Anyone ?
We are going to get to this. Sorry for the delay but had some higher priority issues come up.
Hi, Has there been any progress on this issue since the last update? Thanks in advance!
Hi, Any update ?
After some more research, maybe the problem is due to the MongoDB cloud provider we're using, I'll keep you updated.
I started looking into the issue this week. It looks like it could be an issue with the MongoDBDatastoreProvider, and we might need to override it to get this to work. Let me know, though, if you find something different.
OK I'll give you more context, the mongo cluster created in my usual cloud provider returns the following information:
> db.runCommand({ hello: 1 })
{
hosts: [
'rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local:27017'
],
primary: 'rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local:27017',
me: 'rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-0.rs-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-svc.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.svc.cluster.local:27017',
...
}
So, hosts/primary/me are only private domain names, that an external client can't resolve.
I had some discussion with my cloud provider support team, and after some research in mongo documentation and Faction code, they told me that only the official drivers are supported by their instances.
mongo-java-driver is not in this list, is deprecated and not maintained anymore. The driver that should be used is mongodb-driver-sync.
I don't know if MongoDBDatastoreProvider is another name of the mongo-java-driver, I'm not a MongoDB nor Java expert.
Replacing mongo-java-driver by mongodb-driver-sync was what you have in mind, @summitt ?
We have a version running live in dev that should fix this. We are using mongodb-driver-sync and we needed to update all the hibernate libs as well. We have a bunch of tests to run though but hopefully this will mitigate the issue. I'll let you know when the release is ready.
@sebastienbaillet This is something we are just not going to be able to support right now as its looking like it will be a pretty big rewrite. The issue is that to use the updated mongo driver we have to use an updated version of hibernate. The updated version of hibernate breaks native queries for Mongo above 4.4. Hibernate is something that we will be moving away from soon but it will take quite a bit of planning to make happen.
OK, thank you for your answer.