Search code examples
wcfsilverlightsilverlight-3.0wcf-ria-serviceswcf-configuration

Getting WCF RIA Service Timeout


I am running heavy WCF RIA service operation and getting such error on client-side Silverlight app:

    Uncaught Error: Unhandled Error occurred in Silverlight Application:
Submit operation failed. Для запроса HTTP к 

"https://localhost/MyProject/ClientBin/myservice.svc/binary" has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.


Stack Trace:
   в System.Windows.Ria.OperationBase.Complete(Exception error)
   в System.Windows.Ria.SubmitOperation.Complete(Exception error)
   в System.Windows.Ria.DomainContext.CompleteSubmitChanges(IAsyncResult asyncResult)
   в System.Windows.Ria.DomainContext.<>c__DisplayClassd.<SubmitChanges>b__5(Object )

I am getting such timeout in 1 minute of execution.

My context looks like that:

[EnableClientAccess()]
public class ConfigService : LinqToEntitiesDomainService<MyEntityFrameworkEntities>

Here is code screenshot:

My context class


Solution

  • ach of the settings discussed in this topic are made on the binding itself, either in code or configuration. The following code shows how to programmatically set timeouts on a WCF binding in the context of a self-hosted service.

    public static void Main()
                {
                    Uri baseAddress = new Uri("http://localhost/MyServer/MyService");
    
                    try
                    {
                        ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService));
    
                        WSHttpBinding binding = new WSHttpBinding();
                        binding.OpenTimeout = new TimeSpan(0, 10, 0);
                        binding.CloseTimeout = new TimeSpan(0, 10, 0);
                        binding.SendTimeout = new TimeSpan(0, 10, 0);
                        binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
    
                        serviceHost.AddServiceEndpoint("ICalculator", binding, baseAddress);
                        serviceHost.Open();
    
                        // The service can now be accessed.
                        Console.WriteLine("The service is ready.");
                        Console.WriteLine("Press <ENTER> to terminate service.");
                        Console.WriteLine();
                        Console.ReadLine();
    
                    }
                    catch (CommunicationException ex)
                    {
                        // Handle exception ...
                    }
                }
    

    The following example shows how to configure timeouts on a binding in a configuration file.

    <configuration>
      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding openTimeout="00:10:00" 
                     closeTimeout="00:10:00" 
                     sendTimeout="00:10:00" 
                     receiveTimeout="00:10:00">
            </binding>
          </wsHttpBinding>
        </bindings>
      </system.serviceModel>
    

    you shoud edi For RIA Service

    Either one line after domain context creation:

    ((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
    

    or a partial class

    public partial class LibraryDomainContext
    {
       partial void OnCreated()
       {
          if(DesignerProperties.GetIsInDesignMode(App.Current.RootVisual))
             ((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
       }
    }