launchdarkly/erlang-server-sdk

Could not open connection to host on OTP 26

ndan opened this issue · 2 comments

ndan commented

ldclient couldn't connect on OTP 26

To reproduce
Create a new project with mix new hello_world --sup

.tool-versions

elixir 1.15.4-otp-26
erlang 26.0.2

mix.exs

  defp deps do
    [
      {:ldclient, "~> 2.0", hex: :launchdarkly_server_sdk},
      {:eredis, "1.7.1", override: true}
    ]
  end

applications.ex

  @impl true
  def start(_type, _args) do
    children = [
      # Starts a worker by calling: HelloWorld.Worker.start_link(arg)
      # {HelloWorld.Worker, arg}
    ]


    :ldclient.start_instance(~c"sdk-******")  # <--- Add this line

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: HelloWorld.Supervisor]
    Supervisor.start_link(children, opts)
  end

iex -S mix

10:48:35.279 [error] GenServer #PID<0.449.0> terminating
** (TryClauseError) no try clause matching: {:error, :gun_open_failed, ~c"Could not open connection to host"}
    (ldclient 2.1.1) /Users/dev/hello_world/deps/ldclient/src/ldclient_update_stream_server.erl:129: :ldclient_update_stream_server.do_listen/1
    (ldclient 2.1.1) /Users/dev/hello_world/deps/ldclient/src/ldclient_update_stream_server.erl:89: :ldclient_update_stream_server.handle_info/2
    (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
    (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:listen}
State: %{headers: %{"authorization" => "sdk-*********", "user-agent" => "ErlangClient/2.1.1"}, stream_uri: ~c"https://stream.launchdarkly.com/all", feature_store: :ldclient_storage_ets, backoff: %{max: 30000, value: :listen, initial: 1000, destination: #PID<0.449.0>, current: 1000, active_since: :undefined, attempt: 0}, conn: :undefined, gun_options: %{protocols: [:http], retry: 0, connect_timeout: 2000}, storage_tag: :default}

Revert to OTP 25 to confirm the problem caused by v26
.tool-versions

elixir 1.15.4-otp-25
erlang 25.3.2.5

mix deps.compile
iex -S mix

:ldclient.variation("my-flag", :ldclient_context.new("123"), false) # => true

SDK version
2.1.1

OS/platform
MacOS 13.4.1 (M2)

Hello @ndan,

I need to do some investigation, but it does work if you include http_options.

For erlang that would be a snippet like this in the options.

        http_options => #{
            tls_options => ldclient_config:tls_basic_options()
        }

It appears that new defaults will be needed for OTP 26.

Filed internally as 214652

Thank you,
Ryan

This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.