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

wip #1863

Closed
wants to merge 1 commit into from
Closed

wip #1863

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
32 changes: 16 additions & 16 deletions packages/sync-service/lib/electric/connection/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ defmodule Electric.Connection.Manager do
Process.send_after(self(), :log_lock_connection_status, @lock_status_logging_interval)
{:noreply, %{state | lock_connection_pid: lock_connection_pid}}

{:error, %Postgrex.Error{message: "ssl not available"}} = error ->
if connection_opts[:sslmode] == :require do
error
else
if connection_opts[:sslmode] do
# Only log a warning when there's an explicit sslmode parameter in the database
# config, meaning the user has requested a certain sslmode.
Logger.warning(
"Failed to connect to the database using SSL. Trying again, using an unencrypted connection."
)
end

connection_opts = Keyword.put(connection_opts, :ssl, false)
start_replication_client(electric_instance_id, connection_opts, replication_opts)
end

{:error, reason} ->
handle_connection_error(reason, state, "lock_connection")
end
Expand Down Expand Up @@ -336,22 +352,6 @@ defmodule Electric.Connection.Manager do
{:ok, pid} ->
{:ok, pid, connection_opts}

{:error, %Postgrex.Error{message: "ssl not available"}} = error ->
if connection_opts[:sslmode] == :require do
error
else
if connection_opts[:sslmode] do
# Only log a warning when there's an explicit sslmode parameter in the database
# config, meaning the user has requested a certain sslmode.
Logger.warning(
"Failed to connect to the database using SSL. Trying again, using an unencrypted connection."
)
end

connection_opts = Keyword.put(connection_opts, :ssl, false)
start_replication_client(electric_instance_id, connection_opts, replication_opts)
end

error ->
error
end
Expand Down
Loading