|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
Hi guys,
We are almost ready to deploy EO on our production environment, however, during our tests on our staging Azure deployment (cloud services) we are getting this error:
Time out expired before the page can be loaded. at EO.Base.ThreadRunnerBase.c.a(Int32 A_0, Boolean& A_1) at EO.Base.ThreadRunnerBase.Send(Action action, Int32 timeoutInMS) at EO.Internal.o4.a(ady 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(ady 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, Stream stream, HtmlToPdfOptions options)
We also have an error handler that tries to return an empty pdf document, but it also fails with this error (from event viewer):
Exception information: Exception type: HtmlToPdfException Exception message: The request was canceled. at EO.Internal.o4.a(ady 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(ady A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, String A_5, Boolean A_6) at EO.Pdf.HtmlToPdfSession.a(ady A_0, String A_1, String A_2, Boolean A_3) at EO.Pdf.HtmlToPdfSession.LoadHtml(String html) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options)
I will continue working on this issue all day, but help would be appreciated here. The setup works fine on our dev environments.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, The timeout error normal if you are trying to call back to another page inside your own application/server. The most common reason is a DNS issue which causes your external IP address not reachable from within your server. See here for more details: http://www.essentialobjects.com/doc/web/aspxtopdf/troubleshoot.aspxThe documentation mentioned about ASPXToPDF or MVCToPDF. But it applies to HTML to PDF as well since ASPXToPDF and MVCToPDF are just another layer on top of HTMl to PDF. The solution for this issue is to either use your internal IP address to call ConvertUrl, or add a DNS entry into your host file to point your hostname to your local server (127.0.0.1). Please let us know if that helps you resolve the issue. We tested the second case (empty pdf document) by passing string.Empty to HtmlToPdf.ConvertHtml and it seems to work fine. Can you post a small piece of test code so that we can see if we can reproduce the problem here? Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
Following your advice I stripped the original code to its simplest expression:
using (var memoryStream = new MemoryStream()) using (var streamWriter = new StreamWriter(memoryStream)) { HtmlToPdf.ConvertHtml(string.Empty, streamWriter.BaseStream);
return memoryStream.ToArray(); }
This worked.
The original code looks like this:
HtmlToPdf.Options.OutputArea = new RectangleF(1.0f, 1.0f, 6.5f, 9.0f); HtmlToPdf.Options.PageSize = new SizeF(8.5f, 11.0f); HtmlToPdf.Options.MaxLoadWaitTime = 10000; HtmlToPdf.Options.MinLoadWaitTime = 1000; HtmlToPdf.Options.NoLink = true; HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Dual;
foreach (var cookieKey in cookies.AllKeys) { var cookie = cookies.Get(cookieKey); HtmlToPdf.Options.Cookies.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain)); }
using (var memoryStream = new MemoryStream()) using (var streamWriter = new StreamWriter(memoryStream)) { try { HtmlToPdf.ConvertUrl(url, streamWriter.BaseStream); } catch (Exception ex) { HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Auto; HtmlToPdf.Options.MinLoadWaitTime = 1; HtmlToPdf.ConvertHtml("<b>No Data!</b>", streamWriter.BaseStream); }
return memoryStream.ToArray(); }
Let me know if you see anything weird. I'll investigate the DNS fix in the meantime.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please do investigate the DNS issue first. That is the issue over 90% of the time.
Your code looks fine except that you are trying to duplicate the cookies. This can cause problem for you because if your cookie includes the session cookie then it can cause ASP.NET session deadlock (because by default ASP.NET holds a lock on the session object when processing your page). To confirm if that's the problem, you can temporarily comment out the cookie code and see if it works for you. If it does work without the cookies and you must have the cookies, please try ASPXToPDF/MVCToPDF instead. Those two components have special code to avoid session deadlock.
Another issue in your code is your MinLoadWaitTime is too low. The unit for that properly is in ms, not in seconds. So you may want to set it to 1000 instead of 1.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
I'm still trying to figure out how to do this in Azure. I also tried a few other things without success.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Can you RDP into the server and then edit its host file?
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
I can do that but I'll have to figure out a way to automate that. I'm still getting this:
The connection was reset. at EO.Internal.o4.a(ady 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(ady 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, Stream stream, HtmlToPdfOptions options)
Is that related to the deadlocks?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
The connection reset issue is not caused by deadlocks (deadlock causes time out error). The reset error is usually caused by your Web server refusing to serve the request (by just drop the connection). You will probably want to check your IIS logs to see if it gives you any clues on why it does that.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
I can't make it export a url from the local server. I can make it export external sites but not its own. Nothing helpful in the logs either. I'm out of ideas.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Have you modified your host file and tried ASPXToPDF/MVCToPDF?
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
Had some time to try debugging this issue again. Sadly the host change is not enough. I still get the "The connection was reset" exception. I don't think ASPXToPDF or MVCToPDF is an option for me as I need to wait for some javascript to run before I render.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You need to check your server log to see why your server refuses to serve the request. Connection reset is a different error than time out. Time out usually is because it can not reach and make any connection to your server at all. Connection reset means it can connect but your server immediately closed the connection since it determined that it should refuse that request. As such it appears to be one step closer.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/18/2016 Posts: 7
|
We went through the Event Viewer logs and found nothing, anywhere else I should be looking?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You will need to check your IIS logs. You may also want to use some kind package monitor such as Microsoft Message Analyzer to trace the TCP traffic to find out why. Something else you can try to do is to create a simple plain website and try to convert that website and see if it works. if that works then you can compare the working version and non-working version to find out what triggered the problem.
Thanks!
|
|