views:

594

answers:

2

I'm calling my webservice from a web page and getting a timeout despite setting very high values in my web.config files. This occurs intermittently when the file is usually pretty large but yet the file is still getting uploaded completely (as if the timeout DID NOT occur). Here is a function in my .aspx file which calls my ASMX proxy class:

 private void UploadFile(HttpPostedFile postedFile, string fileNameOnly)
{
    // create an instance of the proxy class to talk to our service; calling it client:
    string strURI = string.Empty;
    WSproxyProject.ASMXProxy.FileService client = new WSproxyProject.ASMXProxy.FileService();
    try
    {
        BinaryReader b = new BinaryReader(postedFile.InputStream);
        byte[] binData = b.ReadBytes(numBytes);
        strURI = client.UploadFile(binData, fileNameOnly, binData.Length);
        txtURI.Text = strURI;
        LogText("SUCCESS: " + fileNameOnly + " has been uploaded. URI=" + strURI);
    }
    catch (Exception ex)
    {
    LogText("UPLOAD ERROR: " + ex.Message.ToString());

    }
}

Please note that my web service on localhost calls another web service which actually stores the final data. I have the following executionTimeout setting in of the web.config in all of the following places:

  1. web.config on my web client project (caller of myWebService)
  2. web.config on myWebService (caller of vendorWebService)
  3. web.config on vendorWebService (resides on another server in my LAN)

The exception caught by the code block above shows the ex.Source to be System.Web.Services and the ex.Message to be:

The operation has timed out

A: 

Some brainstorming:

  • Have you thought about which web service or client is timing out? What does the stack trace show?
  • Each one would begin the process at a slightly different time. Do they have equal time-outs?
  • Is the file complete? It could be the right size, but be corrupted.
  • I know it sounds silly, but is there a never-ending loop or loop that goes for longer than you think it does somewhere?

Hope something in there helps.

cofiem
+1  A: 

What happens if you set the Web Service timeout length in your method?

...
WSproxyProject.ASMXProxy.FileService client = new WSproxyProject.ASMXProxy.FileService();
    client.Timeout = 9999999;
    try
    ...

Perhaps you would also need to set similar timeout properties to other Web Services that the FileService uses.

I had to do that for a Web Service call that utilized an under powered development database. I'd rather have a Web Service prepared to execute longer than needed than throw an exception.

Good luck.

PhillFox
Thank you. The addition of a large Timeout property like you sketched above solved the problem.
John Galt