-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
While working on CDRIVER-3721, I discovered libmongoc interprets connecttimeoutms=0 to mean the option is unset and actually defaults to 10000. So there is no current way to set an unlimited connection timeout. This contradicts the URI options spec, but libmongoc's source comment above mongoc_uri_get_option_as_int32 indicates it's intentional.
* Checks if the URI 'option' is set and of correct type (int32). * The special value '0' is considered as "unset". * This is so users can provide * sprintf("mongodb://localhost/?option=%d", myvalue) style connection
This has happened for other options as well, and required separate getters.
CDRIVER-2056 introduced mongoc_uri_get_local_threshold_option to return 0 if specified.
CDRIVER-1933 introduce the internal _mongoc_uri_get_max_staleness_option to return 0 if specified.
Including connecttimeoutms, these are the other integer options obtained (in non-test code) using the mongoc_uri_get_option_as_int* helpers:
- connecttimeoutms
- socketcheckintervalms
- waitqueuetimeoutms
- sockettimeoutms
- socketcheckintervalms.
- zlibcompressionlevel
- heartbeatfrequencyms
- serverselectiontimeoutms
- wtimeoutms
Cross referencing with the URI options spec, 0 can be meaningful for this subset of options:
- sockettimeoutms. 0 should mean "no timeout".
- connecttimeoutms. 0 should mean "no timeout".
- zlibcompressionlevel. 0 should mean to be no compression.
- wtimeoutms. 0 should mean no timeout. This is ok, since the default is also 0.
In my opinion, libmongoc should always consider an explicit 0 value as being set to 0, not as unset. It would be a backwards breaking behavior change, but libmongoc already breaks the rationale given in mongoc_uri_get_option_as_int32 for maxstalenessseconds and localthresholdms. A URI with those options set to 0 is considered to have them set:
mongodb://localhost/?maxStalenessSeconds=0&localThresholdMS=0
- is depended on by
-
CDRIVER-3721 Define behavior of connectTimeoutMS=0 with streaming protocol
- Backlog
- is related to
-
CDRIVER-2056 mongoc_uri_get_option_as_int32() does not allow a localThresholdMS of zero
- Closed
-
CDRIVER-3167 URI Spec conformance
- Backlog