user1455545
user1455545

Reputation: 185

'socketTimeoutMS' parameter in the connection string

I'm using Mongo server version 2.0.6 And the C# driver DLL version is: 1.3.1.4349

I'm using this connection string:

mongodb://a.b.c.d:27017,e.f.g.h:27017/abcd?connectTimeoutMS=30000;socketTimeoutMS=120000

The issue is that the flag socketTimeoutMS might not be honored, I think. Because if I set it to 1ms, then most of my queries should fail, right?

I hope I've understood this parameter correctly. Can anyone explain what might be going on?

Upvotes: 1

Views: 7240

Answers (1)

Remon van Vliet
Remon van Vliet

Reputation: 18615

The socket timeout parameter is used to time out sockets that are waiting to read or write data. If your server accepts writes and responds with data for reads within 1ms your query will not fail. Also it depends on the underlying OS if such a low timeout is actually honored. It might cap it.

Relevant code :

reads : https://github.com/mongodb/mongo-csharp-driver/blob/8e6850c91893743ebbbd53ebba84d3d4086cdecb/Driver/Internal/MongoConnection.cs#L322-L341

writes : https://github.com/mongodb/mongo-csharp-driver/blob/8e6850c91893743ebbbd53ebba84d3d4086cdecb/Driver/Internal/MongoConnection.cs#L374-L382

Upvotes: 1

Related Questions