Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle SSL and IP Version on Broadcast Changes #1163

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading