Welcome Guest Search | Active Topics | Sign In | Register

Criticle issue with HtmlToPdf (The operation has timed out.) Options
merlyn
Posted: Wednesday, April 8, 2015 1:57:35 PM
Rank: Newbie
Groups: Member

Joined: 4/6/2015
Posts: 1
Hi,

We are developing web application and are using HtmlToPdf for reports.
Since last week on deployment server method HtmlToPdf.ConvertUrl() started hanging on about 2 minutes and throw the exeption "The operation has timed out." But on dev machine this exception does not appears.
Stack trace:
Code:

   at EO.Pdf.Internal.lt.a(a A_0)
   at EO.Pdf.HtmlToPdfSession.a(a A_0)
   at EO.Pdf.HtmlToPdfSession.a(j1 A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, Boolean A_5)
   at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
   at CompIndex.GanderGap.Services.ExportToPdfService.Export(String url, Boolean isSinglePage, ReportVariableParameter variableParameter, String disclaimerInFooter, String header) in c:\GG\Source\GanderGap.Services\ExportToPdfService.cs:line 52
   at CompIndex.GanderGap.Api.Controllers.ExportToPdfController.Download(ExportToPdfModel model) in c:\GG\Source\CompIndex.GanderGap.Api\Controllers\ExportToPdfController.cs:line 43
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
   at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)


Seems like regression bug but I deployed old version of application with tested and worked reports and it does not work now too!
This works now just on my dev machine.
Looks like configuration issue.
I was thinking that may some Windows update guilty of this.
But I setuped old tested version on different VM environments without any Windows updates and always have had this exception.
Enviponments we used:
Deployment server - Win 2012, w\o SQL Server - don't worked
also tryed on clean VMs with
Win2012 w\o any updates + SQL Server Express 2014 - don't worked
Win2008 w\o any updates + SQL Server Express 2014 - don't worked
Dev machine:
Win 8.1 + SQL Server Express 2014 + VS 2012 Up3 - Worked

I tried debug deployment server remotly and replace report url with public "http://yandex.ua" - this is works! I have right screenshot!
But see the same hunging with "http://google.com" - strange.

Now we use old EO.Pdf 2013. But I tried to replace it on the last 2014 in trial mode and had the same result.

Very strange issue and this is blocker for us now.
Please help to solve it.

Controller code
Code: C#
public HttpResponseMessage Download(ExportToPdfModel model)
        {
            var url = model.Href ?? string.Empty;
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Incorrect uri format.");
            }

            var uri = new Uri(url);
            var path = string.Format("{0}://{1}/{2}", 
                                                    HttpContext.Current.Request.Url.Scheme, 
                                                    HttpContext.Current.Request.Url.Authority, 
                                                    uri.Fragment);

            byte[] result = _exportService.Export(
                                                    path, 
                                                    model.IsSinglePage,
                                                    model.VariableParameter,
                                                    HttpUtility.HtmlEncode(_appVariablesService.Disclaimer), 
                                                    model.Header);
}


Service code
Code: C#
public byte[] Export(string url, bool isSinglePage, ReportVariableParameter variableParameter, string disclaimerInFooter, string header)
        {
            string[] urls = variableParameter == null || string.IsNullOrEmpty(variableParameter.Name) ? new[] { url } :
                GenerateUrlsByReplacingVariableParameter(url, variableParameter);

            var options = GetHtmlToPdfOptions(isSinglePage, disclaimerInFooter, header);

            PdfDocument[] docs = new PdfDocument[urls.Length];

            for (int i = 0; i < urls.Length; i++)
            {
                string iUrl = urls[i];
                docs[i] = new PdfDocument();

                // !!!!!!! Exception was here !!!!!!!!!!!!
                HtmlToPdf.ConvertUrl(iUrl, docs[i], options);
            }

            PdfDocument resultDoc = urls.Length > 1 ? PdfDocument.Merge(docs) : docs[0];

            var stream = new MemoryStream();
            resultDoc.Save(stream);

            return stream.ToArray();
        }

        private HtmlToPdfOptions GetHtmlToPdfOptions(bool isSinglePage, string disclaimerInFooter, string header)
        {
            var authenticationCookie = FormsAuthentication.GetAuthCookie(Thread.CurrentPrincipal.Identity.Name, true);

            var cookie = new Cookie
            {
                Domain = authenticationCookie.Domain,
                Expires = authenticationCookie.Expires,
                Name = authenticationCookie.Name,
                Path = authenticationCookie.Path,
                Secure = authenticationCookie.Secure,
                Value = authenticationCookie.Value
            };

            var options = new HtmlToPdfOptions
            {
                NoCache = true,
                MaxLoadWaitTime = 50000,
                MinLoadWaitTime = 5000,
                TriggerMode = HtmlToPdfTriggerMode.Dual,
                PageSize = new SizeF(PdfPageSizes.A4.Height, PdfPageSizes.A4.Width - 1f),
                OutputArea = GetOutputArea(),
                FooterHtmlFormat = disclaimerInFooter,
                HeaderHtmlPosition = 0.35f,
                HeaderHtmlFormat = GetHeaderHtml(header)
            };

            options.Cookies.Add(cookie);

            if (isSinglePage)
            {
                options.AutoFitY = HtmlToPdfAutoFitMode.ShrinkToFit;
            }
            return options;
        }
eo_support
Posted: Wednesday, April 8, 2015 2:27:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

This usually is caused by DNS configuration error on your server. See here for more details:

http://www.essentialobjects.com/doc/4/web/troubleshoot.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.