diff --git a/content/docs/connect/connection-errors.md b/content/docs/connect/connection-errors.md index 591b96da5b..c65a8d2ffc 100644 --- a/content/docs/connect/connection-errors.md +++ b/content/docs/connect/connection-errors.md @@ -20,6 +20,7 @@ This topic describes how to resolve connection errors you may encounter when usi - [You have exceeded the limit of concurrently active endpoints](#you-have-exceeded-the-limit-of-concurrently-active-endpoints) - [Remaining connection slots are reserved for roles with the SUPERUSER attribute](#remaining-connection-slots-are-reserved-for-roles-with-the-superuser-attribute) - [Relation not found](#relation-not-found) +- [Postgrex: DBConnection ConnectionError ssl send: closed](#postgrex-dbconnection-connectionerror-ssl-send-closed) Connection problems are sometimes related to a system issue. To check for system issues, please refer to the [Neon status page](https://neonstatus.com/). @@ -219,4 +220,18 @@ If you are already using connection pooling, you may need to reach out to Neon S This error is often encountered when attempting to set the Postgres `search_path` session variable using a `SET search_path` statement over a pooled connection. For more information and workarounds, please see [Connection pooling in transaction mode](/docs/connect/connection-pooling#connection-pooling-in-transaction-mode). +## Postgrex: DBConnection ConnectionError ssl send: closed + +Postgrex has an `:idle_interval` connection parameter that defines an interval for pinging connections after a period of inactivity. The default setting is `1000ms`. If you rely on Neon's [autosuspend](https://neon.tech/docs/introduction/auto-suspend) feature to scale your compute to zero when your database is not active, this setting will prevent that and you may encounter a `(DBConnection.ConnectionError) ssl send: closed (ecto_sql 3.12.0)` error as a result. As a workaround, you can set the interval to a higher value to allow your Neon compute to suspend. For example: + +```elixir +config :app_name, AppName.Repo + # normal connection options + ... + idle_interval: +:timer.hours(24) +``` + +For additional details, refer to this discussion on our Discord server: [Compute not suspended due to Postgrex idle_interval setting](https://discord.com/channels/1176467419317940276/1295401751574351923/1295419826319265903) + diff --git a/content/docs/guides/elixir-ecto.md b/content/docs/guides/elixir-ecto.md index c67e9e4938..159bf5f7ef 100644 --- a/content/docs/guides/elixir-ecto.md +++ b/content/docs/guides/elixir-ecto.md @@ -94,6 +94,10 @@ Follow these steps to complete the configuration: The `:ssl` option is required to connect to Neon. Postgrex, since v0.18, verifies the server SSL certificate and you need to select CA trust store using `:cacerts` or `:cacertfile` options. You can use the OS-provided CA store by setting `cacerts: :public_key.cacerts_get()`. While not recommended, you can disable certificate verification by setting `ssl: [verify: :verify_none]`. + + Postgrex has an `:idle_interval` connection parameter that defines an interval for pinging connections after a period of inactivity. The default setting is `1000ms`. If you rely on Neon's [autosuspend](https://neon.tech/docs/introduction/auto-suspend) feature to scale your compute to zero when your database is not active, this setting will prevent that. For more, see [Postgrex: DBConnection ConnectionError ssl send: closed](/docs/connect/connection-errors#postgrex-dbconnection-connectionerror-ssl-send-closed). + + 2. The second part of the configuration generated by the `mix ecto.gen.repo` command is the `Ecto.Repo` module, found in `lib/friends/repo.ex`. You shouldn't have to make any changes here, but verify that the following configuration is present: ```elixir