|
23 | 23 | BucketAlreadyExistsException, |
24 | 24 | BucketDoesNotExistException, |
25 | 25 | CollectionAlreadyExistsException, |
| 26 | + CouchbaseException, |
26 | 27 | DocumentNotFoundException, |
27 | 28 | QueryIndexAlreadyExistsException, |
28 | 29 | ScopeAlreadyExistsException, |
29 | 30 | ) |
30 | 31 | from couchbase.management.buckets import CreateBucketSettings |
31 | 32 | from couchbase.management.options import CreatePrimaryQueryIndexOptions |
32 | | -from couchbase.options import ClusterOptions |
| 33 | +from couchbase.options import ClusterOptions, ClusterTimeoutOptions |
33 | 34 | from couchbase.subdocument import upsert |
34 | 35 | from opentelemetry.trace import get_tracer |
35 | 36 |
|
@@ -113,10 +114,22 @@ def __init__(self, url: str, username: str, password: str): |
113 | 114 | self._parse_connection_url(url) |
114 | 115 |
|
115 | 116 | auth = PasswordAuthenticator(username, password) |
116 | | - opts = ClusterOptions(auth) |
| 117 | + opts = ClusterOptions( |
| 118 | + auth, |
| 119 | + timeout_options=ClusterTimeoutOptions( |
| 120 | + # mac dns resolution can be very slow, default timeout is 250ms |
| 121 | + dns_srv_timeout=timedelta(seconds=10) |
| 122 | + ), |
| 123 | + ) |
117 | 124 | self.__username = username |
118 | 125 | self.__password = password |
119 | | - self.__cluster = Cluster(url, opts) |
| 126 | + try: |
| 127 | + self.__cluster = Cluster(url, opts) |
| 128 | + except CouchbaseException as e: |
| 129 | + cbl_warning( |
| 130 | + f"Initial connection to Couchbase Server {url} with {username=} password=<redacted> failed with: {e}" |
| 131 | + ) |
| 132 | + raise |
120 | 133 | self.__cluster.wait_until_ready(timedelta(seconds=10)) |
121 | 134 |
|
122 | 135 | # Create a reusable HTTP session for REST API calls |
|
0 commit comments