MUX api wrapper not working once deployed in a Phoenix app

Hello folks,

I use the MUX API wrapper for Elixir and I’ve been testing locally my Elixir/Phoenix application without issues (managed to create assets, upload videos, list and play videos). However once I deploy the code to the remote fly.io server I get the following error:

** (exit) an exception was raised:
    ** (MatchError) no match of right hand side value: {:error, :enoent}
        (public_key 1.14) pubkey_os_cacerts.erl:38: :pubkey_os_cacerts.get/0
        (inets 9.0.1) httpc.erl:476: :httpc.ssl_verify_host_options/1
        (inets 9.0.1) httpc.erl:1015: anonymous fn/0 in :httpc.http_options_default/0
        (inets 9.0.1) httpc.erl:961: :httpc.http_options/3
        (inets 9.0.1) httpc.erl:771: :httpc.handle_request/9
        (tesla 1.7.0) lib/tesla/adapter/httpc.ex:52: Tesla.Adapter.Httpc.request/2
        (tesla 1.7.0) lib/tesla/adapter/httpc.ex:22: Tesla.Adapter.Httpc.call/2
        (tesla 1.7.0) lib/tesla/middleware/json.ex:54: Tesla.Middleware.JSON.call/3

It seems connected with the ssl certificate which cannot be found, however in the MUX wrapper documentation there is no indication on how to configure this.

Can you please help me addressing the issue? Do you think it is caused by some misconfiguration on the Fly server or there is something wrong with the way I use the MUX wrapper? One note which might help: the Elixir app is accessible on a subdomain which is ssl protected.

I found a workaround, it works using Hackney as a Tesla adapter instead of the native :httpc (by adding this configuration to the config.exs):

config :tesla, :adapter, Tesla.Adapter.Hackney

I still haven’t understood the cause of the issue though… I would be super grateful if anyone could give me a pointer…

1 Like

The default httpc client that ships with erlang requires extra work to do HTTPS. Hackney handles that for you.

2 Likes