When attempting to connect to a dns name longer then 64 chars, mongoc will erroneously fail preemptively because the hostname is longer then HOST_NAME_MAX.
./mongoc-ping "mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me" 2017/02/10 10:03:35.0051: [ 8490]: ERROR: mongoc: Hostname provided in URI is too long, max is 64 chars Invalid hostname or port: mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me
The hostname works just fine, as dns names can be up to 255 chars.
So removing this limitation, and it works fine:
git diff diff --git a/src/mongoc/mongoc-host-list.h b/src/mongoc/mongoc-host-list.h index de1689d..6e1397e 100644 --- a/src/mongoc/mongoc-host-list.h +++ b/src/mongoc/mongoc-host-list.h @@ -34,7 +34,7 @@ BSON_BEGIN_DECLS #define BSON_HOST_NAME_MAX 255 #endif #else -#define BSON_HOST_NAME_MAX HOST_NAME_MAX +#define BSON_HOST_NAME_MAX 255 #endif bjori@TaylorSwift ~/Sources/mongoc master ● ./mongoc-ping "mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me" { "ok" : 1.0 }
- is related to
-
CDRIVER-1129 Silent failure parsing hostnames longer than HOST_NAME_MAX
- Closed