You can specify the connection timeout in the SQL connection string when connecting to the database as follows:
"Data Source=localhost;Initial Catalog=database;Connect Timeout=15"
At the server level, use MSSQLMS to view server properties, and on the Connections page, you can specify the default request timeout.
I'm not quite sure that requests continue to work after the client connection is closed. Requests should not last so long, MSSQL can process large databases, I worked with GB data on it before. Run a performance profile in queries, presumably some well-placed indexes may speed it up, or you might need to rewrite the query.
Update: In accordance with this list, SQL timeouts occur when waiting for confirmation from the server:
Suppose you execute a command, then the command is disconnected. When this happens, the SqlClient driver sends a special 8-byte packet, called the attention packet, to the server. This tells the server to stop executing the current command. When we send a packet of attention, we need to wait for confirmation from the server, and this could theoretically take a lot of time and time. You can also send this package by calling SqlCommand.Cancel on an asynchronous SqlCommand object. This is a special case when we use a 5 second timeout. In most cases, you will never come across this, the server is usually very sensitive to attention packets because they are very low at the network level.
Thus, it seems that after the connection time with the client has expired, a signal is sent to the server to cancel the executed request.
source share