1

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?

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

Can you quote an example, where the time out actually works? Would the following timeout? (assuming 1 second socket-time-out) 1. [Client] Make a connection to the server 2. [Client] Wait for 10 seconds 3. [Client] Then make the query By then the server should timeout, right?
If the query itself would take more than 1 second it should, yes. As you can see in the code the parameter is used and passed to the socket so if that doesn't happen it's an issue with the environment being used. It should work though.
By the way, why is this an issue for you? The defaults values are most appropriate.
well, one of my requirements is to "kill" the query if it takes more than N seconds. So I was thinking if I could do it this way. Can you think of any other way of doing this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.