Print Page | Close Window

Async Operation Timing Out

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1438
Printed Date: 22-Sep-2025 at 1:02am


Topic: Async Operation Timing Out
Posted By: skingaby
Subject: Async Operation Timing Out
Date Posted: 21-Aug-2009 at 1:40pm
I have a class that implements an async behavior. When it runs, it times out after 2 minutes with the following error message:
IdeaBlade.EntityModel.EntityServerException occurred
Message="The HTTP request to 'http://localhost:9009/EntityServer.svc' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout."
Cancelled=false
StackTrace:
       at GcsAg.ClientModel.Test.ContactTest.ContactServiceCallback(InvokeServerMethodEventArgs args)
InnerException: System.TimeoutException
       Message="The HTTP request to 'http://localhost:9009/EntityServer.svc' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout."
       StackTrace:
            at IdeaBlade.EntityModel.EntityServerProxy.InvokeServerMethod(SessionBundle sessionBundle, ITypeWrapper entityManagerType, String typeName, String methodName, Object[] args)
            at IdeaBlade.EntityModel.EntityManager.<InvokeServerMethodAsyncCore>b__74(InvokeServerMethodEventArgs args)
       InnerException: System.Net.WebException
            Message=""
            StackTrace:
                 at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
                 at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
                 at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
            InnerException: System.Net.WebException
                 Message=""
                 StackTrace:
                      at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                      at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                      at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
                 InnerException:


Here's the class:

    public static class ContactAsyncBehaviors
    {
        public static void GetLotusNotesContactsAsync(string user, bool useRealEmail, AsyncCompletedCallback<InvokeServerMethodEventArgs> callback)
        {
            var manager = LocalEntityManager.DefaultManager;
            ServerMethodDelegate mydelegate = new ServerMethodDelegate(GetLotusNotesContacts);
            Guid myToken = Guid.NewGuid();
            manager.InvokeServerMethodAsync(mydelegate, callback, myToken, user, useRealEmail);
        }

        [AllowRpc]
        public static string GetLotusNotesContacts(IPrincipal principal, EntityManager em, params object[] args)
        {
            IService service = (IService)LocalUnityContainer.MainContainer.Resolve(typeof(IService), "LoadLotusNotesContacts");
            service.Execute((string)args[0], (bool)args[1]);
            return (string)service.ReturnValues[0];
        }
    }


The service is instantiated server-side through Unity and the service.Execute method takes a while to run. When the service.Execute is finished, the server-side GetLotusNotesContacts returns a status back to the client as a string.

My web.config says:
<customBinding >

        <binding name="customBinaryBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00" >
          <binaryMessageEncoding >
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
          </binaryMessageEncoding>
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" />
        </binding>
      </customBinding>


and I added a ServiceReferences.ClientConfig that says:
<system.serviceModel>


    <client>
<service name="EntityService" >
        <endpoint address=""   binding="customBinding" bindingConfiguration="customBinaryBinding" contract="IdeaBlade.EntityModel.IEntityServiceContract" />
      </service>
      <service name="IdeaBlade.EntityModel.Server.EntityServer">
        <endpoint address="" binding="customBinding" bindingConfiguration="customBinaryBinding" contract="IdeaBlade.EntityModel.IEntityServerContract" />
      </service>              
              
    </client>

    <bindings>
      <!--The default binding in the Silverlight app is http with binary encoding.
          Max values are set here for testing; you should adjust to your application's requirements.
          If you modify the binding here, be sure to also create/modify the ServiceReferences.ClientConfig
          in the Silverlight application too. Both the client and server sides must agree on
          the binding configuration in order for communications to succeed.
      -->
      <customBinding >
        <binding name="customBinaryBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00" >
          <binaryMessageEncoding >
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
          </binaryMessageEncoding>
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>
</system.serviceModel>




Replies:
Posted By: kimj
Date Posted: 23-Aug-2009 at 7:08pm
Setting a SendTimeout on the client-side binding should fix the problem, although it looks like the ServiceReferences.ClientConfig isn't correct, so is probably being ignored.  There's a sample ClientConfig in the Deployment\Snippets\Silverlight section of the Learning Resources, but here's one too -
 
<configuration>
  <system.serviceModel>
    <client>
      <endpoint name="EntityService"
                address=" http://localhost:9009/EntityService.svc - http://localhost:9009/EntityService.svc "
                binding="customBinding" bindingConfiguration="customBinaryBinding"
                contract="IdeaBlade.EntityModel.IEntityServiceContractAsync"
                />
      <endpoint name="EntityServer"
                address=" http://localhost:9009/EntityServer.svc - http://localhost:9009/EntityServer.svc "
                binding="customBinding" bindingConfiguration="customBinaryBinding"
                contract="IdeaBlade.EntityModel.IEntityServerContractAsync"
                />
    </client>
    <bindings>
      <customBinding>
        <binding name="customBinaryBinding" sendTimeout="00:20:00">
          <binaryMessageEncoding/>
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>
</configuration>



Print Page | Close Window