[Html2PdfConverter] Dynamic URL vs statis URL - Html2PdfConverter

Forge Component
(60)
Published on 17 May by Guilherme Pereira
60 votes
Published on 17 May by Guilherme Pereira

We need to pass URL to GeneratePDF to convert the target page to PDF. 

So if I enter the following in the URL field of GeneratePDF then it work perfectly:

"https://abc.com/MyApp/ConvertToPDF.aspx?HolderId=15"



But, if I assign the same URL to a string variable and enter that variable name in the URL field then it gives "Execution Timeout Expired" error (detail error below).

Reason for using variable is that our target page needs input variable which is dynamic and the url is generated using GetEntryURL. Here is the detail error log that shows up:

Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated.

RequestUrl: https://abc.com/MyApp/ConvertToPDF.aspx?HolderId=15 (Method: GET)

1] Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at OutSystems.HubEdition.Extensibility.Data.ExecutionService.BaseExecutionService.ExecuteNonQuery(IDbCommand cmd)
   at OutSystems.Internal.Db.Command.ExecuteNonQuery(String description, Boolean isApplication, Boolean skipLog, Boolean applyTransformationsToParameters)
   at ssMyApp.ExtendedActions.DeleteHolder(HeContext heContext, Int64 inParamId)
   at ssMyApp.Flows.FlowMainFlow.WBlkActionResultBlock.Preparation(HeContext heContext)
   at ssMyApp.Flows.FlowMainFlow.WBlkActionResultBlock.Page_Load(Object sender, EventArgs e)
   at ssMyApp.Flows.FlowMainFlow.WBlkActionResultBlock.PageStartHook()
   at ASP.blocks_MyAppal_mainflow_actionresultblock_ascx.__DataBind__control2(Object sender, EventArgs e)
   at System.Web.UI.Control.OnDataBinding(EventArgs e)
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.OSUserControl.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.OSUserControl.DataBind()
   at OutSystems.HubEdition.WebWidgets.Container.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.Container.DataBind()
   at OutSystems.HubEdition.WebWidgets.Container.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.Container.DataBind()
   at OutSystems.HubEdition.WebWidgets.Container.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.Container.DataBind()
   at OutSystems.HubEdition.WebWidgets.Container.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.Container.DataBind()
   at OutSystems.HubEdition.WebWidgets.OSUserControl.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.OSUserControl.DataBind()
   at OutSystems.HubEdition.WebWidgets.Form.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.Body.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.OSPage.DataBindChildren()
   at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
   at OutSystems.HubEdition.WebWidgets.OSPage.DataBind()
   at ssMyApp.Flows.FlowMainFlow.ScrnConvertToPDF.DataBind()
   at ssMyApp.Flows.FlowMainFlow.ScrnConvertToPDF.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

[2] The wait operation timed out

Solution

Hi,


By looking at the error it doesn't even seem to be generating from the component.


The stack trace seems to show that the problem is on the call to the Entity action DeleteHolder on the webblock WBlkActionResult.


Can you double check the invocation? If the problem persists can you share your code (or an alternative that can reproduce the problem) so we can take a look?


Cheers,

Guilherme

Solution

Thank you so much Guilherme. That delete action was the problem. Once I removed the delete action, things worked as they are supposed to.

Just wondering aloud... why that delete action is causing problem? All the logic is in webblock and I use the same webblock to show things on the screen and when user want to print, I use the other page with the same webblock and feed it to convert to PDF. It works perfectly in one case but not when I used PDF converter.

Anyway, once again thanks!!!

Hi,


Without looking at a code is hard to say but it may be related with transactions and locks at DB level.


If you do a insert on that table and then try to generate the pdf from a page where the delete action is , the request to the web page done by the component will be done from a diffrent context thus creating a new request and a new transaction. If your initial insert is not commited then the other transaction will be stuck waiting for the first one to complete.


You may validate this assumption by putting the delete action back on your block and do an explicit commit before calling the GeneratePDF.


Hope this helps,

Guilherme