Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exceeded the allotted timeout

Posted on 2010-11-22
17
Medium Priority
?
3,563 Views
Last Modified: 2013-11-12
I Developed a system with Silverlight 4 and  Ria Service.
All runs fine, however when it takes more than 60 seconds the application side client stops,  receiving the message bellow, but the process on the server side runs normaly until the end.
How to configure this time?
Thanks.

Message:
Caused by: Invoke Operation 'MontarRegistrosNFe' failed. The HTTP request to 'http://localhost:52878/ClientBin/NFe-Web-NFeDomainService.svc/binary/MontarRegistrosNFe' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

0
Comment
Question by:Plexo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 3
  • +1
17 Comments
 
LVL 4

Expert Comment

by:dquebe
ID: 34193002
Are you using wcf for the web service, and do you have access to the web.config? There are timeout settings on both the server and client with wcf.
0
 

Author Comment

by:Plexo
ID: 34196662
Hi dquebe.
I´m not using wcf for web service. I´m using Ria Service.
0
 
LVL 4

Expert Comment

by:dquebe
ID: 34200259
I have used Silverlight with WCF, and I believe that RIA uses WCF for the services. I don't know about the server service in your configuration. But I would do the following as next steps (hopefully this helps), identify what the host service is running (old ASP Web Services or new WCF Services). Look at how you attached to the server Service (e.g. did you "Add a Service Reference"). Look for your .config file for the client if you used "Add". It could be under "app.config", "web.config" or "ServiceReferences.ClientConfig". The timeout sounds like the standard timeout period for the client. I have the following code to set the timeouts on my client, but you could do it in the Config file on the binding itself (binding is a reference to the binding that I am using at that time [e.g. System.ServiceModel.BasicHttpBinding] where minutes is a parameter [int] that defines how long I want to wait).


            binding.CloseTimeout = new TimeSpan (0, 1, 0);

            binding.OpenTimeout = new TimeSpan (0, 1, 0);

            binding.ReceiveTimeout = new TimeSpan (0, minutes, 0);

            binding.SendTimeout = new TimeSpan (0, minutes, 0);

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 4

Expert Comment

by:dquebe
ID: 34200276
If you find the "ServiceReferences.ClientConfig" or find one of the other configs, go under the <system.serviceModel><bindings><[bindingtype]<binding> and add an attribute for "receiveTimeout".
0
 

Author Comment

by:Plexo
ID: 34214768
Hi dquebe.

Thank you for your attention.

I had already put the following in the webconfig, but don't change anything.

<bindings>
      <wsHttpBinding>
        <binding
            closeTimeout="00:10:00"
            openTimeout="00:010:00"
            receiveTimeout="00:010:00"
            sendTimeout="00:010:00">
        </binding>
      </wsHttpBinding>
    </bindings>

I did not find any other config, like ServiceReferences.ClientConfig or app app.config.

Thanks
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 34228247
0
 

Author Comment

by:Plexo
ID: 34238877
Hi tovvenki,

I did not find where I can puts the command cited:

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

Do you have an idea where is the "domain context creation" ?

Attached is a print of Solution Explorer.

Thanks

Experts.JPG
0
 
LVL 7

Expert Comment

by:vbigham
ID: 34249820
The domain context creation exists in the generated code.  In order to override it you will need to create a partial class that extends the auto-generated class.  These examples also seems to work for me after I first initialize the domaincontext object before I query anything.

I felt that this one:
http://blogs.msdn.com/b/kylemc/archive/2010/11/03/how-to-change-the-request-timeout-for-wcf-ria-services.aspx

was a bit more explicit and easier to understand what was going on.  I was also able to notice that if I set the SendTimeout to 20 min that the RecieveTimeout was set to 10 min.

What I did was create a method called GetDomainContextWithExtendedTimeout() which initialized a MyDomainContext and then set the timeout on the channelfactory binding then I could use the returned value to load my time intensive query.

Hope this helps,
Vaughn
0
 

Author Comment

by:Plexo
ID: 34283227
Hi vbigham.

I think that the example is for WebServices, and that WCF Ria Service is not the same Ria Service for Silverligh 4.
I did not find the places mentioned in my project.
I´m using Ria Services and Silverlight 4.

Thanks
0
 
LVL 7

Expert Comment

by:vbigham
ID: 34283624
They are one and the same, fyi .NET Ria Services is now called WCF Ria Services.  The reason that you have not found those places would be because you have not created them yet.  What that blog post is showing is to create a static class with a static method that increases the timeout on a domaincontext object.  Then he extends his generated domain context by declaring a "Partial Public Class MyDomainContext" which also extends the OnCreated using a partial method.  All of that to make sure that the endpoint does not get used before the timeout has been set.  This would also be appropriate if you are declaring your DomainContext in xaml using Ria Controls.  If you are declaring your context in code you can create it and then probably call that one liner just after it is instantiated.

I can help you make it work.  If you wouldn't mind just post the code or the xaml of the Ria Context / Controls that would eventually be getting the timeout error and I can give you some steps and some code to increase the timeout.
0
 

Author Comment

by:Plexo
ID: 34292291
Hi Vaughn.
Thanks for your atention.
I have a simple project simulating the problem. It use thread.sleep for to cause the situation.
How can I send to you ?
I made a .zip file and I tried send by attachment, but I received the message:
 "The extension of one or more files in the archive is not in the list of allowed extensions: SimulaTimeOut/SimulaTimeOut/App.xaml"

Regards,
Sidney


Regards,
Sidney

0
 
LVL 7

Expert Comment

by:vbigham
ID: 34292828
I'm not sure how we can share a project.  I don't have an email address that will accept source code either (It all gets rejected).  

One thing we can do though.. If you will post another screen shot with this test project structure (solution explorer).  Then just post the code for the domain service class that simulates the problem.  I will recreate the project really quick and post the exact steps and code to resolve in the test project so that you can see exactly how to do it in your actual project.

Thanks,
Vaughn
0
 
LVL 7

Accepted Solution

by:
vbigham earned 2000 total points
ID: 34293506
I built a test project with the same name as yours and can show you a couple things about what this solution entails.

Add a file to your silverlight project called:  RiaExtendTimeOutUtility.cs  and copy the following code into that file.
 
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.DomainServices.Client;
using System.Reflection;
using System.ServiceModel;


namespace SimulaTimeOut
{
    public static class RiaExtendTimeOutUtility
    {
        public static void ChangeRiaSendTimeout(DomainContext ctx, TimeSpan sendTimeout)
        {
            PropertyInfo channelFactoryProperty = ctx.DomainClient.GetType().GetProperty("ChannelFactory");

            if (channelFactoryProperty == null)
            {
                throw new InvalidOperationException("There is no 'ChannelFactory' property on the DomainClient.");
            }

            ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(ctx.DomainClient, null);

            factory.Endpoint.Binding.SendTimeout = sendTimeout;
        }
    }
}

Open in new window



I created an empty Domain service class in the web project.  It just sleeps the thread like you suggested then returns an integer.  Here is what that looks like.  I called this file ExtraLengthyDomainService.cs
namespace SimulaTimeOut.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;


    // TODO: Create methods containing your application logic.
    [EnableClientAccess()]
    public class ExtraLengthyDomainService : DomainService
    {
        [Invoke()]
        public Int32 GetRandomInteger()
        {
            System.Threading.Thread.Sleep(120000);
            return 1000;
        }
    }
}

Open in new window


Now I have added another file to the Silverlight project called: ExtraLengthyDomainContext.cs
This is the extension of the already generated ExtraLengthyDomainContext, and here is what that looks like:
NOTE: To make the Namespace match all I had to do was add ".Web"  If your domain service class is in another namespace you would add that after the ".Web", for example if it resides in "Services" you would add ".Web.Services".  This is important to make sure that this code applies to the same object.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SimulaTimeOut.Web
{
    public partial class ExtraLengthyDomainContext
    {
        partial void OnCreated()
        {
            // Set a break point to ensure that it works (must have the matching namespace)
            TimeSpan tenMinutes = TimeSpan.FromMinutes(10);
            RiaExtendTimeOutUtility.ChangeRiaSendTimeout(this, tenMinutes);
        }
    }
}

Open in new window

Now, whenever you instantiate a context of this type, it will have the extended timeout.

Then I have just created my context in code in the main page just for testing.  When I comment out the "partial void OnCreated()" method the call has the timeout error.  But as long as that method extends the timeout, the invoke operation comes back fine.  Here is the MainPage.xaml.cs:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.DomainServices.Client;

namespace SimulaTimeOut
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            Web.ExtraLengthyDomainContext ctx = new Web.ExtraLengthyDomainContext();

            InvokeOperation<Int32> invOp = ctx.GetRandomInteger();
            invOp.Completed +=new EventHandler(invOp_Completed);            
        }

        void invOp_Completed(object sender, EventArgs e)
        {
            InvokeOperation<Int32> invOp = sender as InvokeOperation<Int32>;

            if (invOp.HasError)
            {
                MessageBox.Show(invOp.Error.Message);
                invOp.MarkErrorAsHandled();
            }
            else
            {
                MessageBox.Show(invOp.Value.ToString());
            }
        }
    }
}

Open in new window

0
 

Author Comment

by:Plexo
ID: 34295168
Hi Vaughn .

Now I understood.
Thanks for the example.

Regards,
Sidney
0
 

Author Comment

by:Plexo
ID: 34295242
Sorry I was mistaken in point.
How can I repeat?
0
 

Author Comment

by:Plexo
ID: 34295305
Now the score is right.
Thanks
0
 
LVL 7

Expert Comment

by:vbigham
ID: 34295543
Glad to help, thank you very much!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question