[CSHARP-1934] Set TImeOut for RunCommand Created: 08/Mar/17  Updated: 27/Oct/23  Resolved: 08/Mar/17

Status: Closed
Project: C# Driver
Component/s: API, Documentation
Affects Version/s: 2.4.2
Fix Version/s: None

Type: Task Priority: Blocker - P1
Reporter: Ummer Irshad Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS : Windows 7
.Net : 4.6.1



 Description   

Is there any way to reduce the default command timeout of 30000ms of RunCommand in below code?

var command = new BsonDocument { { "dbstats", 1 } };
 
var stats = database.RunCommand<BsonDocument>(command);
 
Console.WriteLine(stats.ToJson()); // do something with the stats

Thanks in advance.
Irshad.



 Comments   
Comment by Robert Stam [ 08/Mar/17 ]

There is no way to apply a timeout to RunCommand.

You could use a short ReadTimeout, but that's generally not desirable as the server won't know the client has timed out and will continue executing the operation all the way to the end anyway. When a ReadTimeout occurs the connection must be discarded, which interferes with the efficient operation of the connection pool.

Generated at Wed Feb 07 21:41:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.