Difference between command timeout and connection time out

What is the difference between connection timeout and command timeout?

In our application sometimes it is showing a timeout error. When we increased the command timeout value to 100(from default 30), its working. Is there any issue in increasing the command timeout value.

Thanks,
Mahesh

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

ConnectionTimeout is the time your code should wait when trying to open the connection to the DB

CommandTimeout is the time your code should wait for your SQL code to execute.

If you’re hitting command timeout your SQL is taking a long time to execute, so you may want to check your query. If your query is optimized, then raising the command timeout may be the only thing to make your client work.

Method 2

As mentioned connection timeout is timeout for establishing connection with DB server. Command timeout is timeout for command execution.

Extending command timeout is possible but when doing this in ASP.NET you should be also aware of request execution timeout. You can set it in code via Server.ScriptTimeout or globally in httpRuntime/@executionTimeout. Default value for .NET 2.0+ is 110s.

But generally this is most probably wrong way to architect application. Unless you are doing some heavy online reporting wich will be rarely executed no one will want to use it.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x