Server closed connection
Hi! My name is Abhi! I am running a Vercel application with Supabase on a medium sized instance.
My connection limit is 3. Pool Timeout is 60. My Vercel max function duration is 300s
Before this, I was receiving a huge amount of connection time outs. Now I am being plagued with Server closed the connection.
After I upgraded the instance or even restarted the db the problem happens after some time.
Could anyone help me understand why this is happening and how to remedy it!
5 Replies
Just to be sure, did you use the right URLs to connect to Supabase?
Direct should end with 5432, regular with 6543
Yep I am using the Pooler uri on 6543
Hey 👋
Can you try using metrics preview feature and check if there are any idle connections causing this issue?
You should be able to get these stats via metrics
https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/metrics
Where do I call this metrics endpoint? After queries are executed?
Do I expose an api route in my Vercel app to do call this?
Supabase informed that during this period the logs
Thu Jun 06 2024 21:20:13 UTC could not send end-of-streaming message to primary: SSL connection has been closed unexpectedly
Thu Jun 06 2024 21:00:22 UTC could not send end-of-streaming message to primary: SSL connection has been closed unexpectedly
Thu Jun 06 2024 21:00:22 UTC could not send end-of-streaming message to primary: SSL connection has been closed unexpectedly
You would need to enable the metrics preview feature as descibed here:
https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/metrics#step-2-enable-the-feature-flag-in-the-prisma-schema-file
After which, you should be able to log the metrics and optionally send it to StatsD to visualize it:
https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/metrics#use-prisma-client-metrics-with-statsd
https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-prometheus-format