New Posts New Posts RSS Feed: Async Operation Timing Out
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Async Operation Timing Out

 Post Reply Post Reply
Author
skingaby View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 23-Apr-2008
Location: United States
Posts: 146
Post Options Post Options   Quote skingaby Quote  Post ReplyReply Direct Link To This Post Topic: Async Operation Timing Out
    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>



Edited by skingaby - 21-Aug-2009 at 1:42pm
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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"
                binding="customBinding" bindingConfiguration="customBinaryBinding"
                contract="IdeaBlade.EntityModel.IEntityServiceContractAsync"
                />
      <endpoint name="EntityServer"
                address="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>
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down