Welcome Guest Search | Active Topics | Sign In | Register

Time out when using HtmlToPdf.ConvertHtml() Options
Voicebooth Ltd
Posted: Wednesday, May 3, 2017 5:40:48 PM
Rank: Member
Groups: Member

Joined: 7/17/2016
Posts: 17
Hi guys,

I continue my testing on the latest version of EO.Pdf after you guys fixed the transparency canvas problems I raised a few weeks ago, and there's a definite improvement in the quality since your changes.

I'm onto the next phase of testing with the latest EO.Pdf, but I'm encountering problems I've not seen before. I am using EO.Pdf and EO.Base 17.1.42.0

My PDF generation is multi-threaded, with the following options being set on a per-thread basis:

Code: C#
HtmlToPdf.Options.PageSize = PdfPageSizes.A4;
            HtmlToPdf.Options.OutputArea = new RectangleF(0, 0.5f, 8.263889f, 10.6944447f);
            HtmlToPdf.Options.BaseUrl = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configuration.Storage.Path);
            HtmlToPdf.Options.NoCache = true;
            HtmlToPdf.Options.JpegQualityLevel = 100;
            EO.Base.Runtime.EnableEOWP = true;


After that code is executed, I do:

Code: C#
HtmlToPdf.ConvertHtml(content, stream.BaseStream);
            HtmlToPdf.ClearResult();


Each thread is rendering the PDF to a file stream, based on the same template HTML but with modified content. In each instance, the PDF that ultimately renders is maybe 2-3 pages long.

I'm rendering five PDFs in parallel, using five different threads, but I'm seeing a lot of intermittent errors like this:

Code: C#
System.Exception: Time out expired before the page can be loaded.
   at EO.Internal.pa.a(adj A_0, String A_1, String A_2, String A_3, Int32 A_4, Int32 A_5, String A_6, Boolean A_7)
   at EO.Pdf.HtmlToPdfSession.a(adj A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, String A_5, Boolean A_6)
   at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options)
   at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options)
   at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream)


I use the term intermittent because on some runs, two out of the five threads error, sometimes three out of five error, and so on. As mentioned before, the code renders the same HTML template, which includes an reference to a css page also held on the same folder locally - there are no external domains where the HTML calls resources from.

I notice upon run time that the initial creation of PDFs, which is spawning some eowp.exe processes, is really slow, even when the generation of PDF is successfully completing - it takes 60 seconds for the completion of the creation of PDFs. Once the first PDF is created, any subsequent PDFs created on that same thread will be instant, so the initialisation of the eowp.exe process takes a substantial amount of time.

In instances where one of the threads error, any subsequent PDF creation on that same thread will also error. So in the case of my last test run, four out of five threads worked correctly, with the fifth thread erroring. When I then re-ran the process, the same identical thread errored again, with all other threads working correctly.

It appears once a thread "errors", it stays "broken" throughout the lifespan of my service process (Win32 service) until it's restarted.


What am I doing wrong?



Alvaro
eo_support
Posted: Thursday, May 4, 2017 1:07:33 PM
Rank: Administration
Groups: Administration

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

It's unusual to take 60 seconds for the first run to convert just a few pages. A couple of things that can cause time out error for you:

1. If your DLLs are on a network drive. This will significantly increases the time to load and initialize the DLL, thus can significantly increases the first conversion time. If this is the case, move the DLLs to local drive;
2. If you have third party security/AntiVirus program that interferes with the DLLs. If this is the case, try to temporarily disable them;
3. Your server maybe slow to serve contents referenced in the HTML. For example, if your HTML references a chart that is dynamically generated, then the converter will wait until the chart image to be generated and loaded. If the web server is slow to generate this image, the conversion can timeout. This often causes significant first run delay because the time it takes for the web server application to start. To find out whether this is the problem, try to convert self contained HTML instead;

We do not know what can cause a thread to enter a broken state and not being able to recover. That part appears to be a bug on our side. If you can create a test project that can demonstrate this problem, we will be happy to investigate further.

Thanks!
Voicebooth Ltd
Posted: Thursday, May 4, 2017 3:00:46 PM
Rank: Member
Groups: Member

Joined: 7/17/2016
Posts: 17
Hi,

Unfortunately none of those points apply to our project, all the testing of the platform is done locally on a very souped-up PC, there's no network access, anti virus is disabled, and there's no HTTP web server at play here, it's all direct disk access by a Windows service.

I will try and and create a console application using a similar pattern to the service to see if the problem still occurs, and send it through.


Alvaro
eo_support
Posted: Thursday, May 4, 2017 3:03:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
No problem. We will look into it as soon as we receive it.
LINQ IT
Posted: Monday, May 15, 2017 9:41:53 PM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2015
Posts: 42
I am running into the same errors with this version as well; however, I cannot reproduce it in a console application. My PDF is less than 1 page in length.
Voicebooth Ltd
Posted: Tuesday, May 16, 2017 4:46:06 AM
Rank: Member
Groups: Member

Joined: 7/17/2016
Posts: 17
We've been a bit busy with some other things but we'll try and get a sample application done that hopefully replicates the problem, and email it in.


Alvaro
idlife
Posted: Thursday, May 18, 2017 8:46:41 AM
Rank: Newbie
Groups: Member

Joined: 1/16/2014
Posts: 2
I am having the same issue as described by Alvaro. For weeks and weeks no problem then suddenly the last two days we were inundated by these phantom timeouts. I say phantom because the pdf files were created in the target folder. Not sure if in all cases. Once the process is restarted the error goes away.

Lajos Szoke
eo_support
Posted: Thursday, May 18, 2017 8:58:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
LSzoke wrote:
I am having the same issue as described by Alvaro. For weeks and weeks no problem then suddenly the last two days we were inundated by these phantom timeouts. I say phantom because the pdf files were created in the target folder. Not sure if in all cases. Once the process is restarted the error goes away.

Lajos Szoke


Hi,

Build 17.1.55 did resolve an issue that can cause time out, so you can give it try. Even though it does appear that the problem is caused by something else since it appeared suddenly --- most likely related to some changes in your environment.

Thanks!
idlife
Posted: Thursday, May 18, 2017 9:56:43 AM
Rank: Newbie
Groups: Member

Joined: 1/16/2014
Posts: 2
Thanks, I will give it a try although there had been no environmental changes.

Lajos Szoke
Voicebooth Ltd
Posted: Monday, June 5, 2017 3:17:20 PM
Rank: Member
Groups: Member

Joined: 7/17/2016
Posts: 17
Hi all,

I wanted to drop an update on this issue, as there's been some progress.

I've been trying to put together a solution today to send in as a test project, and in the process of testing my existing changes to make sure the problem is still there, I upgraded to the latest build (17.1.65).

I've found that my consistent time out problem has disappeared, as first reported on this thread.

I have ended up doing some simulations of generating 10,000 PDFs using 8 concurrent threads, and using eowp.exe this has nicely churned through it all without problems.

I'll keep doing some more testing with a few different scenarios.


Regards,
Alvaro
eo_support
Posted: Monday, June 5, 2017 4:01:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
Great. Thanks for the update. Please keep us posted.
Trisha
Posted: Tuesday, June 13, 2017 4:59:30 PM
Rank: Newbie
Groups: Member

Joined: 6/13/2017
Posts: 2
I'm getting the same error, except I'm using the trial of the latest build, 17.1.76. The error occurs on ConvertUrl() with html files on the local disk. Should I be trying an older version, 17.1.65?

Here is the error I'm getting:
Code:

Result Message:    
Test method PrintServerTest.UnitTest1.TestMethod1c threw exception:
System.Exception: Time out expired before the page can be loaded.
Result StackTrace:    
at EO.Internal.o9.a(ade A_0, String A_1, String A_2, String A_3, Int32 A_4, Int32 A_5, String A_6, Boolean A_7)
   at EO.Pdf.HtmlToPdfSession.a(ade A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, String A_5, Boolean A_6)
   at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
   at EO.Pdf.HtmlToPdf.ConvertUrl(String url, String pdfFileName, HtmlToPdfOptions options)
   at EO.Pdf.HtmlToPdf.ConvertUrl(String url, String pdfFileName)
   at UnitTest1.TestMethod1c() in e:\UnitTest1.cs:line 76




The code I execute a few times to get the error (all the html files exist on the local disk):
Code:

            EO.Pdf.HtmlToPdf.Options.OutputArea = new System.Drawing.RectangleF(0.2f, 0.2f, 8.1f, 10.6f);
            string[] htmlFiles = { "C:\\Test\\borders.html", "C:\\Test\\borders_original.html", "C:\\Test\\bordersInline.html", "C:\\Test\\test3.html", "C:\\Test\\test4.html", "C:\\Test\\test5.html" };
            foreach (string s in htmlFiles)
            {
                string d = "C:\\Test\\output.pdf";
                HtmlToPdf.ConvertUrl(s, d);
            }
eo_support
Posted: Tuesday, June 13, 2017 9:47:49 PM
Rank: Administration
Groups: Administration

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

We are not aware of any such problems with .76 build. Can you try to isolate the problem into a test project and send the test project to us? See here for more details on how to send test project to us:

https://www.essentialobjects.com/forum/test_project.aspx

We will look into it as soon as we receive it.

Thanks!

Trisha
Posted: Wednesday, June 14, 2017 1:54:13 PM
Rank: Newbie
Groups: Member

Joined: 6/13/2017
Posts: 2
While making a test project, I couldn't get the error to happen again. Never mind.
eo_support
Posted: Wednesday, June 14, 2017 3:19:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
No problem. Thanks for the update.
Voicebooth Ltd
Posted: Wednesday, June 14, 2017 5:42:30 PM
Rank: Member
Groups: Member

Joined: 7/17/2016
Posts: 17
We've now got 17.1.65 running in production without problems so far.

Many thanks for all the help guys.



Alvaro


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.