Error DynamicPdf.HtmlConverter.NET v1.3.0

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Converter for .NET (v3)  /  Error DynamicPdf.HtmlConverter.NET v1.3.0

DynamicPDF Converter for .NET (v3) Forum

I am has error to  converter html to pdf:

Conversion failed. Refer inner exception for details.
 at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()<---
sending the request. ---> System.Net.Http.CurlException: Couldn't connect to server
   at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
   at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference`1 easyWrapper, CURLcode messageResult)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<GetStringAsyncCore>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()
   --- End of inner exception stack trace ---
   at ceTe.DynamicPDF.HtmlConverter.Converter.l.MoveNext()
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.CurlException: Couldn't connect to server
   at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
   at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference`1 easyWrapper, CURLcode messageResult)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<GetStringAsyncCore>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ceTe.DynamicPDF.Conversion.DevTools.RuntimeCLI.Chrome.<CreateNewSession>d__6.MoveNext()<---



.Net Core 2.2;
Host: Openshift -container Linux
Posted by a ceTe Software moderator
Hello,

HtmlConverter uses Chromium to do the conversions, do you have chromium installed in your Linux machine? Also, you will have to set the chromium path using the ChromiumProcessPath property of the Converter. And please try setting a temp directory to avoid any file access issues. Below is the sample code for this.

Converter.ChromiumProcessPath = @"/home/hc/chrome";
Converter.TemporaryDirectory = @"/home/hc/tmp/";

Please run the chromium with the no-sandbox and disable-gpu tags. Here are the docker commands:
    RUN echo '#!/bin/bash' > chrome
    RUN echo 'chromium --no-sandbox --disable-gpu $@' >> chrome
    RUN chmod +x chrome

We are continuing to look into this. We'll post an update once we have more information.

Thanks,
ceTe Software Support Team.
There is another way to fix this problem?
In my environment openshift blocks to run chrome

Posted by a ceTe Software moderator
Hello,

DynamicPDF HTML Converter needs access to Chrome or a Chromium browser. Here are the instructions to run HTML Converter on Linux:

Install Chrome or a Chromium-based browser on the system. These instructions will vary depending on the type of Linux you are using.

Test the installation to make sure it runs without errors in headless mode by running this command:
    chromium --headless --no-sandbox --no-gpu

Set the static Converter.ChromiumProcessPath property to the path to your Chromium installation before doing the first conversion.

Set the static Converter.TemporaryDirectory to a directory on your system with read/write access for the application that is using DynamicPDF HTML Converter.

By default, we start the Chromium process on a Linux machine with the “--no-sandbox --no-gpu” arguments. On some systems, you may need to add additional arguments. To do this, set the static Converter.ChromiumProcessArgs property as follows:
    Converter.ChromiumProcessArgs += " --specific-arg"

Thanks,
ceTe Software Support Team.
Hi.

Is it possible to remove the default parameters, and only use parameters provided like this: Converter.ChromiumProcessArgs = "--params..."?
Seems like the default parameters is always included, the newest version of the Chromium browser doesn't need the --siable-gpu parameter if on uses --headless.

Christer.
Posted by a ceTe Software moderator
Hello Christer,

These flags are being added by default on Linux because most systems require them. If you would like to suppress the default parameters, you can set an empty string or specify specific parameters.

Here is a pseudocode.
Converter.ChromiumProcessArgs = "";
or
Converter.ChromiumProcessArgs = " --specific-args";

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 9:44 PM.