rahul190201
Chromic_pdf ChromicPDF.Connection.ConnectionLostError in production environment
After pushing some recent changes in my Phoenix application where I am using ChromicPDF to generate pdf files, I am getting the following error on my production server:
17:12:40.189 [error] GenServer #PID<0.2553.0> terminating
** (ChromicPDF.Connection.ConnectionLostError) Chrome has stopped or was terminated by an external program.
If this happened while you were printing a PDF, this may be a problem with Chrome itelf.
If this happens at startup and you are running inside a Docker container with a Linux-based
image, please see the "Chrome Sandbox in Docker containers" section of the documentation.
Either way, to see Chrome's error output, configure ChromicPDF with the option
discard_stderr: false
(chromic_pdf 1.17.0) lib/chromic_pdf/pdf/connection/local.ex:49: ChromicPDF.Connection.Local.handle_info/2
(stdlib 3.15.2) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.15.2) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.369492350.2377121803.250295>, :port, #Port<0.21>, :normal}
I am not getting this error on my local. I tried to follow the documentation in the section Chrome Sandbox in Docker containers, but couldn’t make the required changes successfully. I tried using ChatGPT for help with making changes in the dockerfile of the project and the ingress and deployment .yml files but it did not work.
I am passing the following to the chromic_pdf_opts in application.ex
session_pool: [timeout: 60_000, size: 10, checkout_timeout: 60_000]
I was trying a fix suggested by claude.ai, so I updated the config as follows in config.ex
# chromic_pdf config for all environments
config :chromic_pdf, :chrome_args, [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
"--remote-debugging-port=9222"
]
Even this did not solve the problem.
Please let me know if I should share any other details which could help better understand the problem. Any help or suggestions would be highly appreciated.
Marked As Solved
shamanime
I also deploy with Docker.
With the debian:bookworm-20240904-slim image, I only install chromium without adding any source.
My only prod config is:
config :myapp, ChromicPDF,
no_sandbox: true
And then I start it on the application with:
{ChromicPDF, Application.get_env(:myapp, ChromicPDF)},
Also Liked
shamanime
Add that to your options and inspect the new output when it errors.
-
Are you able to print anything in prod? Is the error happening at startup or when you’re printing?
-
How are you installing Chrome in your prod server?
rahul190201
Last Post!
rahul190201
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









