Connection timeout in .net web application that uses a webservice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Techie23
    New Member
    • Oct 2008
    • 1

    Connection timeout in .net web application that uses a webservice

    Hi,

    I have a .net web application that calls a webservice method to index a list. It works fine for small list. But for very large list, the application is throwing a run time error after 15minutes because of connection timeout.
    I have tried using httpRuntime executionTimeou t property in web.config, but no use of it. The problem still exists.

    Please help me to solve this issue.
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    Originally posted by Techie23
    Hi,

    I have a .net web application that calls a webservice method to index a list. It works fine for small list. But for very large list, the application is throwing a run time error after 15minutes because of connection timeout.
    I have tried using httpRuntime executionTimeou t property in web.config, but no use of it. The problem still exists.

    Please help me to solve this issue.
    To communicate with the web service use Asynchronous Programming approach... Webservice may take longtime to respond to your request .. and you dont want your code to be blockin... (freeze... wont respond to UI)..Check articles for asynchronous programming....

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      With the help of delegate you can call "BeginInvok e" on any function.. By calling BeginInvoke you make the call to your function asynchronous...

      Code:
      using System.Threading;
      using System.Runtime.Remoting.Messaging;
      class Program
          {
              public delegate String AsyDel();
              public AsyDel delAsy;
             
              static void Main(string[] args)
              {
                  Program p=new Program();
      
                  p.delAsy=new AsyDel(p.Some);
                  //Define a delegate to call "ANY" function Asynchronous...
                  // Delegate should have same signature...
      
                  p.delAsy.BeginInvoke(new AsyncCallback(p.After_Some),null);
                  // 
      
      
      
                  Console.ReadLine();
      
      
                  Console.WriteLine("After ");
      
              }
      
              public  string  Some()
              {            
                      Console.WriteLine("Doin Something Asy");
                      Thread.Sleep(1000);
                      return "C#";
                  
                  
              }
      
              public void After_Some(IAsyncResult res)
              {
                  AsyncResult ar = (AsyncResult)res;
                  string ss="Def";
      
      
      
                 delAsy = (AsyDel)ar.AsyncDelegate;
      
                  try
                  {
                      ss = delAsy.EndInvoke(res);
                  }
      
                  catch (Exception ex)
                  {
                      Console.WriteLine(ex.Message.ToString());
                  }
      
                  Console.WriteLine(ss);
      
              }
          }
      Here in the above prog... public string Some() is a function that returns string... Normally the call would be "linear"... that is the main thread callin the function and blocking until the function is finished...
      However here we have done it Asynchronously. . As soon as the function has completed you get notified as "After_Some " is called...
      Simply replace the call to function with call to web service...You get the picture.. Web service may/ maynot respond.. still your application wont hang.. or crash...

      Comment

      • PRR
        Recognized Expert Contributor
        • Dec 2007
        • 750

        #4
        Originally posted by Techie23
        Hi,

        I have a .net web application that calls a webservice method to index a list. It works fine for small list. But for very large list, the application is throwing a run time error after 15minutes because of connection timeout.
        I have tried using httpRuntime executionTimeou t property in web.config, but no use of it. The problem still exists.

        Please help me to solve this issue.
        If you wish to increase the timeout of your web service .. you could do this
        serviceObject.T imeout = 100000; // in milli seconds...
        // or you could use -1... thats i guess infinite...
        httpRuntime executionTimeou t property default is 90 secs... I guess changing that in addition to the timout property of web service object should set things right..
        i guess 15 min a lil too long... what exactly is your web method does?

        Comment

        • PRR
          Recognized Expert Contributor
          • Dec 2007
          • 750

          #5
          You should also take a look at this
          Web service requests from ASP.NET applications
          You should also increase the Web service minWorkerThread s and executionTimeou t

          Comment

          Working...