I am running a C# 2010 windows application that calls a C# 2008 console application to make various calls to a web service. I am getting the following timeout error. I am wondering what part of the application I should look at to determine what is causing the timeout? Both applications are compiled in debug mode.
I am wondering if you can tell in the application what timeout parameter(s) need to be changed? What coding changes would I make to prevent the timeout errors from occuring?
Here is the error message:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
2013-01-24 16:40:03.3082|ERROR|Sample|************* Stack Trace *******************
2013-01-24 16:40:03.3238|ERROR|Sample| at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Booleanasync)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object parentArgs, Object userArgs, ICompiledSubQuery subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo queryInfos, IObjectReaderFactory factory, Object userArguments, ICompiledSubQuery subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
As your stack trace mentions SQLClient in almost every line I would suspect it is your database query that is timing out, that will live in your WCF. You can change both the the connection timeout and/or the command timeout.
Never underestimate the power of human stupidity
I am wondering what part of the application I should look at to determine what is causing the timeout
If it is a large application and especially if it is a system (multiple applications like you're having) you might want to consider some serious logging. The timestamps in the log can immediately tell you where the culprit is.
I suggest thinking the logging mechanism over for a while before jumping in a quick and dirty solution. Good logging saved my day in numerous times.
What coding changes would I make to prevent the timeout errors from occuring?
What you need to do FIRST is determine what is being processed (presuming some SQL.)
The SECOND you need to determine what a reasonable time for that process to take - especially from the business side.
As an example it unreasonable to expect a user to wait for an hour for a web site to finish processing a request (where the web app is blocked until it is done.)
To "fix" a problem like this depends on the specifics of the problem but some or all of the following might be necessary but this is not a complete list.
- Tune the database/schema
- Adjust the SQL operation parameters or SQL itself.
- Rearch/design the interface to preclude such operations.
- Rearch/design the interface to create a batch processing system where a request is posted, some other process processes each request, and some time later a result is created, then the caller at some later time, may submit another (different) request to retrieve the result.
Don't. If you have a recordId, assume it exists and delete it - catch the exception if it did not. Adding checks like the one you proposed might say it exist, and still be deleted (by someone else) an instance later (unless it's an atomic operation, which I doubt).
if you delete it while it doesn't exist SQL will return something like: "0 rows deleted".
Deletefrom tableX where myconstraint='Myconstraint';
--> query returned in 10 ms: 0 rows deleted
If you do it in code you can get that by reading out the NrOfRowsAffected property when doing an ExecuteNonQuery statement. Same goes for Insert and Update queries eg.
as someone already replied, checking if it exists is inaccurate at best and doesn't add any functional advantage.
if you really, really must check it. Perform a select query perhaps with a count.
Select count(id) from tableX where myconstraint='Myconstraint'
I need to do a simple drag and drop procedure, but I dont know why this code isn´t working...
/// Interaction logic for MainWindow.xaml
public partial class MainWindow : Window
Hey folks!! Hope you can help me with my client code.
Först I debugg the Server wich is an consoleapplication and the server starts, secondly I debugg the Client, I put a nickname value to the nickNameTextBox and click on Connect (button2) the compiler stops at this code line
from the button 2 handler - unless you have pressed Button1 first, the connection has not been established and it will likely throw an exception - probably the one you are complaining about.
Personally, I would have a "Connect" method, which checked if you are connected and does so if not - and call it from both click events. (I would probably also make it return the stream instead of using a class level variable directly in the two event handlers).
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
Thank you mate I appreciate your help, I changed it to this code,
the reason I commented out
because the compiler stops there when I debugg telling me that a socket is already connected, now the compiler runs withour errors but the server consoleAppplication doesn't receive any msg at all when I send it from sendTextBox..
privatevoid button1_Click(object sender, EventArgs e)
if (serverStream == null)
MessageBox.Show("Please connect to a server.");
readData = "Conected to Chat Server ...";
serverStream = clientSocket.GetStream();
byte outStream = System.Text.Encoding.ASCII.GetBytes(sendTextBox.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
Thread ctThread = new Thread(getMessage);
The compiler stops on this code under the getMessage method
serverStream.Read(inStream, 0, buffSize);
Last Visit: 31-Dec-99 18:00 Last Update: 18-Mar-18 23:45