Skip to content

Commit 9c768d7

Browse files
committed
Run ping command in Client.Ping
GODRIVER-1068 Change-Id: I1af4c04d7c365be3bde7acc7324332d6c5130fb5
1 parent 6745193 commit 9c768d7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mongo/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ func (c *Client) Ping(ctx context.Context, rp *readpref.ReadPref) error {
136136
rp = c.readPreference
137137
}
138138

139-
_, err := c.topology.SelectServer(ctx, description.ReadPrefSelector(rp))
140-
return replaceErrors(err)
139+
db := c.Database("admin")
140+
res := db.RunCommand(ctx, bson.D{
141+
{"ping", 1},
142+
})
143+
144+
return replaceErrors(res.Err())
141145
}
142146

143147
// StartSession starts a new session.

0 commit comments

Comments
 (0)