Skip to content

Commit

Permalink
fix: Handle SSL and IP Version on Broadcast Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecabaco committed Oct 16, 2024
1 parent 2922658 commit e37c830
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions lib/realtime/broadcast_changes/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,23 @@ defmodule Realtime.BroadcastChanges.Handler do
def start_link(%__MODULE__{tenant_id: tenant_id} = attrs) do
tenant = Cache.get_tenant_by_external_id(tenant_id)
connection_opts = Database.from_tenant(tenant, "realtime_broadcast_changes", :stop, true)

connection_opts = [
name: {:via, Registry, {Realtime.Registry.Unique, tenant_id}},
hostname: connection_opts.host,
username: connection_opts.user,
password: connection_opts.pass,
database: connection_opts.name,
port: connection_opts.port,
parameters: [
application_name: connection_opts.application_name
{:ok, ip_version} = Database.detect_ip_version(connection_opts.host)

connection_opts =
[
name: {:via, Registry, {Realtime.Registry.Unique, tenant_id}},
hostname: connection_opts.host,
username: connection_opts.user,
password: connection_opts.pass,
database: connection_opts.name,
port: String.to_integer(connection_opts.port),
ssl: connection_opts.ssl_enforced,
socket_options: [ip_version],
backoff_type: :stop,
parameters: [
application_name: connection_opts.application_name
]
]
]

case Postgrex.ReplicationConnection.start_link(__MODULE__, attrs, connection_opts) do
{:ok, pid} -> {:ok, pid}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.33.0",
version: "2.33.1",
elixir: "~> 1.16.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit e37c830

Please sign in to comment.