Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mongodb+srv:// protocol #222

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Conversation

malarzm
Copy link
Contributor

@malarzm malarzm commented Mar 2, 2018

@jmikola
Copy link
Contributor

jmikola commented Mar 2, 2018

For reference, mongodb+srv:// is documented in initial seedlist discovery specification, which is implemented in ext-mongodb 1.4.0.

@malarzm malarzm force-pushed the uri-prepend branch 2 times, most recently from 322f973 to 79b4454 Compare March 2, 2018 15:32
yield ['localhost', 'mongodb://localhost'];
yield ['mongodb://localhost', 'mongodb://localhost'];
if (version_compare(phpversion('mongodb'), '1.4.0', '>=')) {
yield ['mongodb+srv://localhost', 'mongodb+srv://localhost'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libmongoc requires that there by only a single hostname and that the hostname string contain at least two dots (https://github.com/mongodb/mongo-c-driver/blob/30085af2124de68fd5ad714309f3ea2688489dee/src/mongoc/mongoc-uri.c#L430). I'm not sure if requiring two dots is correct, as the specification only suggests a hostname and domain suffix. I'll follow up if this turns out to be a libmongoc bug, but let's use foo.example.com for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this actually isn't a bug. I misread the spec. It requires {hostname}.{domainname}, where a domain name includes its own dot before the TLD suffix.

There's also a test for this in not-enough-parts.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for finding this!

@alcaeus
Copy link
Owner

alcaeus commented Mar 5, 2018

@malarzm Two builds failed: the first is the test suite sanity check which runs the test suite against ext-mongo to ensure the behavior expected in tests is the same behavior shown by ext-mongo. Since we're "only" talking URL parsing here, I'll let you decide whether you want to fix it or whether you want to skip it using skipTestIf(extension_loaded('mongo'));.

The second build that failed seems to have an issue with your data provider. I suppose the lowest version doesn't like your data provider. I'll try bumping phpunit dependency in a separate PR, should be done shortly.

@alcaeus alcaeus added this to the 1.1.5 milestone Mar 5, 2018
@alcaeus alcaeus added the bug label Mar 5, 2018
@alcaeus
Copy link
Owner

alcaeus commented Mar 5, 2018

Thanks @malarzm!

@alcaeus alcaeus merged commit 3e2ec06 into alcaeus:master Mar 5, 2018
@malarzm malarzm deleted the uri-prepend branch March 5, 2018 10:29
@miljojohn
Copy link

Failed to parse MongoDB URI: 'mongodb+srv://testuser:passwordfotheuser@cluster0-3xdfs.mongodb.net'. Invalid URI Schema, expecting 'mongodb://'."

@alcaeus
Copy link
Owner

alcaeus commented Mar 7, 2018

Which versions of mongodb/mongodb and ext-mongodb do you have installed?

@miljojohn
Copy link

  • Installing mongodb/mongodb (1.2.0): Loading from cache
  • Installing alcaeus/mongo-php-adapter (1.1.5): Loading from cache

@alcaeus
Copy link
Owner

alcaeus commented Mar 7, 2018

Please post the version of ext-mongodb you’re using. To get you started, you need at least version 1.4.0 of the driver to be using the mongodb+srv protocol, as written above.

@miljojohn
Copy link

MongoDB support => enabled
MongoDB extension version => 1.4.2
MongoDB extension stability => stable
libbson bundled version => 1.9.3
libmongoc bundled version => 1.9.3
libmongoc SSL => enabled
libmongoc SSL library => OpenSSL
libmongoc crypto => enabled
libmongoc crypto library => libcrypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled

@miljojohn
Copy link

Now its working . Thank you.
but now i got error Cannot create SSL client. SSL is not enabled in this build.","class":"MongoDB\Driver\Exception\InvalidArgumentException
How can i figure it out

@alcaeus
Copy link
Owner

alcaeus commented Mar 7, 2018

That is a different issue that we're already discussing in doctrine/DoctrineMongoDBBundle#452. Please let's keep the discussion in one place. Thanks.

Repository owner locked as off-topic and limited conversation to collaborators Mar 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MONGODB ATLAS CONNECTION ISSUE
4 participants