electric-sql / electric

Local-first sync layer for web and mobile apps. Build reactive, realtime, local-first apps directly on Postgres.
https://electric-sql.com
Apache License 2.0
5.37k stars 124 forks source link

MODULE ERROR: Electric.Replication.PostgresConnector when trying to connect to Supabase #1388

Closed maysayson closed 2 weeks ago

maysayson commented 2 weeks ago

Hello!

I have been trying to implement ElectricSQL with Supabase on my Flutter application using the electricsql and electricsql_cli libraries. I was able to connect to Supabase when using the 0.6.0 version of the cli library (uses electric-sql/electric:0.10) but when I try to upgrade to a more recent version (using electric-sql/electric:0.11 or electric-sql/electric:0.12), it is giving me this issue whenever I do dart run electricsql_cli start.

I am using an IPv4 network and have purchased the IPv4 add-on for my Supabase

Attaching to electric-1
electric-1  | 10:50:21.944 pid=<0.3063.0> [info] Starting ElectricSQL 0.12.0 in direct_writes mode.
electric-1  | 10:50:21.949 pid=<0.3064.0> [info] Running Electric.Plug.Router with Bandit 1.1.3 at 0.0.0.0:5133 (http)
electric-1  | 10:50:21.953 pid=<0.3378.0> origin=postgres_1 [info] Postgres.Client.with_conn(%{database: ~c"postgres", host: ~c"db.cqfxdrhfbhndsunpddnj.supabase.co", ip_addr: ~c"18.130.41.129", ipv6: false, nulls: [nil, :null, :undefined], password: ~c"******", port: 5432, ssl: true, ssl_opts: [server_name_indication: ~c"db.cqfxdrhfbhndsunpddnj.supabase.co"], timeout: 5000, username: ~c"postgres"})
electric-1  | 10:50:22.604 pid=<0.3382.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.321 pid=<0.3378.0> origin=postgres_1 [info] Successfully initialized origin postgres_1 at extension version 
electric-1  | 10:50:42.323 pid=<0.3387.0> [info] Starting Proxy server listening on port 65432
electric-1  | 10:50:42.995 pid=<0.3400.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.995 pid=<0.3393.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.997 pid=<0.3392.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.997 pid=<0.3394.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.998 pid=<0.3399.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:42.998 pid=<0.3397.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:43.000 pid=<0.3398.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:43.001 pid=<0.3391.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:43.006 pid=<0.3396.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:43.006 pid=<0.3395.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
electric-1  |      Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
electric-1  | 
electric-1  | 10:50:44.333 pid=<0.3378.0> origin=postgres_1 [error] PostgresConnectorSup failed to start child Electric.Satellite.ClientReconnectionInfo with reason: {%DBConnection.ConnectionError{message: "connection not available and request was dropped from queue after 2000ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:\n\n  1. Ensuring your database is available and that you can connect to it\n  2. Tracking down slow queries and making sure they are running fast enough\n  3. Increasing the pool_size (although this increases resource consumption)\n  4. Allowing requests to wait longer by increasing :queue_target and :queue_interval\n\nSee DBConnection.start_link/2 for more information\n", severity: :error, reason: :queue_timeout}, [{DBConnection, :run, 3, [file: ~c"lib/db_connection.ex", line: 960, error_info: %{module: Exception}]}, {Electric.Satellite.ClientReconnectionInfo, :init, 1, [file: ~c"lib/electric/satellite/client_reconnection_info.ex", line: 1028]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 851]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 814]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 240]}]}.
electric-1  | ▓ ┌────────────────────────────────────────────────────────┐
electric-1  | ▓ │  MODULE ERROR: Electric.Replication.PostgresConnector  │
electric-1  | ▓ ┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙
electric-1  | ▓ 
electric-1  | ▓ Failed to start child Electric.Satellite.ClientReconnectionInfo:
electric-1  | ▓   {%DBConnection.ConnectionError{message: "connection not available and request was dropped from queue after 2000ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:\n\n  1. Ensuring your database is available and that you can connect to it\n  2. Tracking down slow queries and making sure they are running fast enough\n  3. Increasing the pool_size (although this increases resource consumption)\n  4. Allowing requests to wait longer by increasing :queue_target and :queue_interval\n\nSee DBConnection.start_link/2 for more information\n", severity: :error, reason: :queue_timeout}, [{DBConnection, :run, 3, [file: ~c"lib/db_connection.ex", line: 960, error_info: %{module: Exception}]}, {Electric.Satellite.ClientReconnectionInfo, :init, 1, [file: ~c"lib/electric/satellite/client_reconnection_info.ex", line: 1028]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 851]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 814]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 240]}]}
electric-1  | ▓ 
electric-1  | ▓ Please file a new issue on GitHub[1], including the contents of this error.
electric-1  | ▓ 
electric-1  | ▓ [1]: https://github.com/electric-sql/electric/issues
electric-1  | 
electric-1  | ••• Shutting down •••
electric-1  | 
electric-1  | [os_mon] memory supervisor port (memsup): Erlang has closed
electric-1  | [os_mon] cpu supervisor port (cpu_sup): Erlang has closed
electric-1 exited with code 1

Thank you for the help

linear[bot] commented 2 weeks ago

VAX-1975 MODULE ERROR: Electric.Replication.PostgresConnector when trying to connect to Supabase

alco commented 2 weeks ago

Hey @maysayson .

Tell us more about your setup. Are you using Supabase SaaS or self-hosted? Where does the sync service (Electric's server component) run?

The error you get may be due to a high latency between the sync service and the database if there's a large geographical distance between the two.

maysayson commented 2 weeks ago

@alco Hello! I am using Supabase SaaS (London region) and is currently running the electric sync service locally on Docker. I am currently in SEA region

maysayson commented 2 weeks ago

setup a server to host the sync service on and set its region to the same region as the one on Supabase. the sync service is now able to connect to Supabase. Thank you for the help