Skip to content

Commit 3343501

Browse files
Jérôme Lebelhanumantmk
authored andcommitted
adding more information when can't connect
1 parent 2d46a3b commit 3343501

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/mongoc/mongoc-client.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ mongoc_client_connect_tcp (const mongoc_uri_t *uri,
141141
rp->ai_addr,
142142
(socklen_t)rp->ai_addrlen,
143143
expire_at)) {
144+
char errmsg[32];
145+
146+
bson_strerror_r (mongoc_socket_errno (sock), errmsg, sizeof errmsg);
147+
MONGOC_WARNING ("Failed to connect, error: %d, %s\n",
148+
mongoc_socket_errno(sock),
149+
errmsg);
144150
mongoc_socket_destroy (sock);
145151
sock = NULL;
146152
continue;
@@ -153,7 +159,8 @@ mongoc_client_connect_tcp (const mongoc_uri_t *uri,
153159
bson_set_error (error,
154160
MONGOC_ERROR_STREAM,
155161
MONGOC_ERROR_STREAM_CONNECT,
156-
"Failed to connect to target host.");
162+
"Failed to connect to target host: %s",
163+
host->host_and_port);
157164
freeaddrinfo (result);
158165
RETURN (NULL);
159166
}

0 commit comments

Comments
 (0)