[CDRIVER-4728] SRV URI should allow port number Created: 20/Sep/23  Updated: 27/Oct/23  Resolved: 21/Sep/23

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Minh Luu Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

Summary

Mongo C driver (libmongoc) currently does not allow port numbers with an SRV URI, and has an error that goes "Port numbers are prohibited in an SRV URI". The line of code is here.

However, according to MongoDB official documentation, SRV URI can actually have port number.

Could this be a Mongo C driver bug?

Environment

_Version of the C / CXX driver: All versions up to mongo-c-driver 1.24.4

The host OS, version, and architecture: All

The C / CXX compiler and version: All

MongoDB server version and topology (standalone, replica set, or sharded cluster): All

How to Reproduce

Use a MongoDB SRV URI (mongodb+srv://) which includes a port with the Mongo C Driver.

Additional Background

Please provide any additional background information that may be helpful in diagnosing the bug.



 Comments   
Comment by Minh Luu [ 21/Sep/23 ]

I see, thank you for the clarification Kevin! I've opened DOCSP-33198 for this.

Comment by Kevin Albertson [ 20/Sep/23 ]

minh.luu@mongodb.com thank you for the report. I expect "mongodb+srv" URIs to have one host, and no port. This is noted in the driver specification:

It is an error to specify a port in a connection string with the mongodb+srv protocol, and the driver MUST raise a parse error and MUST NOT do DNS resolution or contact hosts.

It is an error to specify more than one host name in a connection string with the mongodb+srv protocol, and the driver MUST raise a parse error and MUST NOT do DNS resolution or contact hosts.

There may be more than one resolved SRV record, and the record includes a port. The test DNS records used by driver testing can be used to observe:

dig SRV _mongodb._tcp.test1.test.build.10gen.cc

Results in these records:

_mongodb._tcp.test1.test.build.10gen.cc. 300 IN SRV 10 1 27017 localhost.test.build.10gen.cc.
_mongodb._tcp.test1.test.build.10gen.cc. 300 IN SRV 10 1 27018 localhost.test.build.10gen.cc.

I expect this is a documentation bug, and suggest filing a DOCSP ticket.

Generated at Wed Feb 07 21:21:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.