Web Service 30 second timeout
I struck a small issue with one of our old apps here at work today.
I’ve got an app that calls a web service which executes a MS SQL stored procedure to do some processing.
The webservice call in the app was bombing out after 30 seconds. Unfortunately I found many places to change various timeouts through the web service and the app and none of them helped me with my 30 second issue.
The 30 second issue turned out to be the CommandTimeout setting on the SqlCommand in the webservice.
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["WBConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand("Transfer", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ListNumber", listNumber); cmd.Parameters.AddWithValue("@Date", date); cmd.Parameters.AddWithValue("@ListDate", listDate); cmd.CommandTimeout = 300; cmd.Connection.Open(); return (string)cmd.ExecuteScalar();
Additionally I found you can also set another timeout for the web service calls at the client end, this must default to a more than 30 seconds (100000 milliseconds I think)
using (PayeesService svc = new PayeesService()) { svc.Timeout = 300000; statusTB.Text += "Connected!" + Environment.NewLine;
We’ll see how this goes in the future, it’s fixed up the couple of large batches that needed to get through.