Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf Maximum number of session reached Options
Jeff
Posted: Friday, August 21, 2015 9:40:17 AM
Rank: Newbie
Groups: Member

Joined: 8/21/2015
Posts: 2
I wrote a console program test the performance of Html to Pdf, program is simple, concurrency 10, loop 105 times, I repeat run the program several times, each time loop at 98 exception encountered :
Quote:
Conversion failed. System.Exception: Maximum number of session reached.
EO.Internal.aix.f.a(aba A_0)
EO.Internal.aix.f.a(Byte[] A_0)


The code is as follows:
Code: C#
using System;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

using EO.Pdf;

namespace ConsoleApp {
    internal class Program {
        private static void Main(string[] args) {
            const string html = @"<!DOCTYPE html>
                                  <html lang=""zh-CN"">
                                    <head>
                                        <meta charset=""utf-8"">
                                        <meta http-equiv=""X-UA-Compatible"" content=""IE=edge"">
                                        <meta name=""viewport"" content=""width=device-width, initial-scale=1"">
                                        <title>Bootstrap 101 Template</title>
                                    </head>
                                    <body>
                                        <h1>Hello,Word!</h1>
                                    </body>
                                 </html>";

            while (true) {
                for (var i = 0; i < 105; i++) {
                    Parallel.For(0, 10, j => {
                        Console.WriteLine("start convert {0}, time:{1}, tid:{2}", j, DateTime.Now, Thread.CurrentThread.ManagedThreadId);
                        try {
                            GetPdfStreamFromHtmlString(html);
                        }
                        catch (Exception ex) {
                            Console.WriteLine("Error:{0}", ex.Message);
                        }
                    });

                    Console.WriteLine("======================[{0}]=======================", i);
                }
                Console.WriteLine("Press Enter Continue...");
                Console.ReadLine();
            }
        }

        private static Stream GetPdfStreamFromHtmlString(string htmlString, string baseUrl = null) {
            var pdfStream = new MemoryStream();

            var htmlToPdfOptions = new HtmlToPdfOptions {
                PageSize = new SizeF(3.937008F, 3.937008F),
                NoScript = true,
                NoLink = true,
                RepeatTableHeaderAndFooter = false,
                OutputArea = new RectangleF(0, 0, 3.937008F, 3.937008F)
            };

            if (!string.IsNullOrWhiteSpace(baseUrl)) {
                htmlToPdfOptions.BaseUrl = baseUrl;
            }

            HtmlToPdf.ConvertHtml(htmlString, pdfStream, htmlToPdfOptions);

            pdfStream.Position = 0;
            return pdfStream;
        }

    }
}
eo_support
Posted: Friday, August 21, 2015 9:54:31 AM
Rank: Administration
Groups: Administration

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

This is normal. You can not create an unlimited number of concurrency conversion task. Allowing so would quickly overload your system. You can try to increase his property to increase the number of con-current task allowed:

http://www.essentialobjects.com/doc/eo.pdf.htmltopdf.maxconcurrenttaskcount.aspx

However please keep in mind that if your system can not handle that many con-current task, then it will fail somewhere else (out of memory exception, time out exception, etc). When that happens, it will be much more difficult for you to manage/troubleshoot those exceptions than this one. This is exactly the purpose of the MaxConcurrentTaskCount property.

Thanks!
Jeff
Posted: Friday, August 21, 2015 10:27:32 AM
Rank: Newbie
Groups: Member

Joined: 8/21/2015
Posts: 2
Thank you for your quick reply

I set MaxConcurrentTaskCount 10 :
Code: C#
HtmlToPdf.MaxConcurrentTaskCount = 10;

And concurrency reduced 2 :
Code: C#
Parallel.For(0, 2,


Still exception occurs at 98 times, the program even hang up...

eo_support
Posted: Monday, August 24, 2015 10:10:32 AM
Rank: Administration
Groups: Administration

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

We have confirmed this to be a bug on our end. We will fix it and post an update as soon as possible.

Thanks!
Jim Baron
Posted: Monday, August 24, 2015 4:09:13 PM
Rank: Newbie
Groups: Member

Joined: 8/24/2015
Posts: 1
Do you have an ETA for this fix? I am evaluating your component for use in our Software but this is the second time in a week that I have run into problems with EO.
eo_support
Posted: Monday, August 24, 2015 4:12:07 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Jim Baron wrote:
Do you have an ETA for this fix? I am evaluating your component for use in our Software but this is the second time in a week that I have run into problems with EO.


I am sorry about the problem. We already have this problem fixed in our internal builds. The official build will be out very soon.

Thanks!
eo_support
Posted: Tuesday, August 25, 2015 11:22:09 AM
Rank: Administration
Groups: Administration

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

This is just to let you know that we have posted the new build with the fix. You can download the new build from our download page.

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.