Welcome Guest Search | Active Topics | Sign In | Register

ASPXToPDF in Web Farms Options
OleOj
Posted: Wednesday, September 24, 2014 3:47:35 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
Hi,

In the proof of concept project we have now moved the ASPXToPDF to our test web farm.
The binding is https.
As expected the url address is not working and I have read your documentation about troubleshooting ASPXToPDF.

At the moment it is a 2003 server, but it will soon be moved to a 2012 server.
Do you have any recommendation/worked on it on how to set up the DNS mappings on server in the web farm.
We need to hit the same server in the web farm as the original call.
Will the insert of dns mapping in the host file on each server solve the problem.
I need to check with the infrastructure team if it is possible to do.

I got an exception on the RenderToPDF since the url address didn't exist.
The url address was not an https, it was an http like this.

Original address.
https://test.xxxx.xxx/Default.aspx

The address returned in the exception when calling RenderToPDF.
http://test.xxxx.xxx/Default.aspx
Perhaps you know the reason for that.

Best Regards
Ole Oscar
OleOj
Posted: Wednesday, September 24, 2014 5:07:59 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
Hi,
Some extra information from our infrastructure team.

OK, so if I’m understanding this correctly, you want to put a hosts entry on each server, that maps test.xxxxxx.xxx to the IP address of the local server, correct? I’m not sure that this will work well for you for the following reasons:
• The change will cause the server to resolve its own name incorrectly. This has caused problems in the past when we’ve attempted it, specifically in that it broke licencing for some third party software installed on the servers.
• The web sites are listening on non-default ports (:XXXX), you’d need to be able to handle this within the application.
• There was a fix deployed into the global.asax in order to get DNN working in a load balanced environment – this change captures any headers containing the :XXXX port and removes them so that they work correctly in DNN. This effectively means that the site cannot be accessed locally on the server, which would presumably prevent Essential Objects from working.

Best Regards
Ole Oscar
eo_support
Posted: Wednesday, September 24, 2014 8:43:56 AM
Rank: Administration
Groups: Administration

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

You do not have to add an entry to map to the external host name to your local IP. The root of the problem is a Url can not be loaded on your server. We don't care what DNS entry you have. But the HTML to PDF converter must be able to load the dependency resource on your server. Consider that you try to convert the following HTML:

Code: HTML/ASPX
<img src="logo.gif" />


The converter goes through the following steps in order to render this image. Note that all steps occurs on your web server:

1. Take the current page Url from HttpContext.Current.Request.Url. So if your original address is https://test.xxx.xxx/Default.aspx but somehow the converter sees http://test.xxx.xxx/Default.aspx, then you will want to check your HttpContext.Current.Request.Url first. If that property gives you https, then there is no reason we get http;

2. Take the base Url from your current page Url. For example, if the page Url is http://test.xxx.xxx/Default.aspx, then baseUrl is http://test.xxx.xxx;

3. Set HtmlToPdf.Options.BaseUrl to the base Url value acquired in step 2;

4. Call BeforeRender event. You can change HtmlToPdf.Options.BaseUrl in this step. For example, if you have a DNS issue and you do not want to address that, you can change your BaseUrl to IP form in this case;

5. The converter uses the base Url to expand the partial Url to a full Url. For example, if you did not change BaseUrl in step 4, then the full Url for the image would be "http://test.xxx.xxx/logo.gif";

6. Use the full Url in step 5 to load the resource. We don't care how you fix your DNS or network or server, as soon as the Url on step 5 can be used to load the image then it will work. If that Url fails, then the converter fails;

Hope this gives you enough insight to resolve the issue.

Thanks!
OleOj
Posted: Wednesday, September 24, 2014 11:00:02 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
Hi,
It worked in a way, I tested to set it to an invalid address to check what happened. The links to the parts within the page did not work as expected, but the main page did. I was expecting to get a timeout for the main page as we did with the load balancer. Is it something else I need to set to change the request url for the main page so that it is using the "local" address.

Regards
Ole Oscar
eo_support
Posted: Wednesday, September 24, 2014 11:55:32 AM
Rank: Administration
Groups: Administration

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

The main page Url has nothing to do with ASPXToPDF except that ASPXToPDF uses it to derive BaseUrl. ASPXToPDF works by intercepting the ASP.NET output for the page and then pass the result HTML to HtmlToPdf.ConvertHtml. So it does not issue a request to your web server for the main page. It only requests the dependencies from your web server. The main page request is the request from your client computer browser to your web server, this request triggers ASPXToPDF, in another word, the main request is already done before the converter starts.

Thanks
OleOj
Posted: Thursday, September 25, 2014 3:39:09 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
The call from the client side is https://test.xxxx.xxx/Default.aspx

This is the exception we get when we call the RenderAsPDF() behind the load balancer after aprox. one minute.


The requested url, <http://test.xxxx.xxx/Default.aspx>, could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The requested url, <http://test.xxxx.xxx/Default.aspx>, could not be found.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The requested url, <http://test.xxxx.xxx/Default.aspx>, could not be found.]
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase) +332
System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData) +425
System.Action`1.EndInvoke(IAsyncResult result) +0
ManagedFusion.Rewriter.ProxyAsyncHandler.EndProcessRequest(IAsyncResult result) +42
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +86

Best Regards
Ole Oscar
eo_support
Posted: Thursday, September 25, 2014 8:56:40 AM
Rank: Administration
Groups: Administration

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

This is something you will need to fix on your load balancer/Web server. The request has to reach our converter promptly. The converter does not make up the http://test.xxx.xxx/Default.aspx Url itself. So it has to be coming from your web server. As we have already explained in our early post, we take the url from HttpContext.Request.Url. As such that's what you need to fix first.

Thanks
OleOj
Posted: Thursday, October 2, 2014 9:00:35 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
Hi,
We are still struggling with this problem. Is it possible to save the html content of the HtmlDocument in the HtmlToPdfResult object.
I want to check the produced html on my local computer to try to figure out what going on.

Our infrastructure team says that they don't think it has something with the load balancer, but a problem with the component and DNN witch is the portal solution.
My problem is that i don't get access to the server park on the other side of the load balancer and they don't have time to help me until next week.

Best Regards
Ole Oscar
eo_support
Posted: Thursday, October 2, 2014 5:12:37 PM
Rank: Administration
Groups: Administration

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

Unfortunately no. By the time you get HtmlToPdfResult, the conversion is already done and the original HTML is already discarded. However if you just want to check the HTML, you can check it with a network package monitor and that should be able to show you everything that traveled through your network between your browser and your server.

In your case, I think you should focus on the difference between the Urls. Specifically, why when you type in "https://test.xxxx.xxx/Default.aspx" in your browser, but when it gets to your server it becomes "http://test.xxxx.xxx/Default.aspx". As we have already explained to you earlier, we get the current Url through HttpContext.Current.Request.Url. So your question should be why "https" becomes "http" when it reaches your server. This should not have anything to do with us, you should be able to reproduce this problem without using our DLL at all.

This is why it appears that you are looking at the wrong direction that you are trying to check the HTML. The root of the problem seems to be that BaseUrl is wrong so that's what you need to fix. Specifically, you need to do either of these three things:

1. Change your network/load balancer configuration to make sure your application sees HttpContext.Current.Request.Url as "https" instead of "http" since you already know that the "http" Url does not work (based on your " requested url, <http://test.xxxx.xxx/Default.aspx>, could not be found" error message);

--- OR ---

2. Override HtmlToPdf.Options.BaseUrl in your code inside BeforeRender event. See step #4 in our original reply.

--- OR ---

3. Make sure the http Url works. That is, to fix your configuration so that if you type "http://test.xxxx.xxx/Default.aspx" in a browser directly on the server and it works fine. Current this does not work;

Option 1 and option 2 allows you to stick with https, where options 3 stick with http and make http work on your web server. Either of the above should fix the problem for you. So HTML probably should not be the focus for you.

This does not appear to have anything to do with DNN. It looks much more like a simple server configuration issue.

Hope this makes sense to you and help you resolve the issue.

Thanks!
OleOj
Posted: Friday, October 3, 2014 3:24:44 AM
Rank: Member
Groups: Member

Joined: 9/16/2014
Posts: 11
Many thanks for the answer.
I have figured out the reason for the http instead of https. They told me that after the load balancer, they are only using http and therefore the reason for http.
In the call stack of the error I see that it calls something called ManagedFusion. This is something that I don't have on my computer or I could not find it. On the internet I have found that there exist a product with that name. It's an url rewriter. I have asked the infrastructure team if they knows anything about that one. I am waiting for an reply from them.

Best Regards
Ole Oscar
eo_support
Posted: Friday, October 3, 2014 1:15:59 PM
Rank: Administration
Groups: Administration

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

You might want to consider option 2 and option 3 in our previous reply. You do not have to wait for anybody in order to use option 2. Option 3 you will need your server/infrastructure team to make the change for you. Option 1 could be the hardest because if that's how your server works now then your infrastructure team must have a reason to do it that way. In any case, this is a configuration issue that you need to address on your side.

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.