supabase / realtime

Broadcast, Presence, and Postgres Changes via WebSockets
https://supabase.com/realtime
Apache License 2.0
6.83k stars 315 forks source link

Fix: detect IPv6 and use appropriate socket for Realtime.Repo #1170

Open tvogel opened 1 month ago

tvogel commented 1 month ago

What kind of change does this PR introduce?

This change allows to use a DB_HOST connected via IPv6.

What is the current behavior?

When the DB_HOST resolves to an IPv6, connecting to the database fails with :nxdomain.

What is the new behavior?

The connection is established successfully.

Additional context

Uses logic from Realtime.Database.detect_ip_version/1 and applies it to the Realtime.Repo socket_options, too. Unfortunately, I was not able to directly call Realtime.Database.detect_ip_version/1 from runtime.exs. I am an Elixir newbie, so there may be a more elegant way.

vercel[bot] commented 1 month ago

@tvogel is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

filipecabaco commented 1 month ago

this is already automatically by Realtime.Database.detect_ip_version/1 and we already run it in production with IPv6

is your use case not covered by this?

tvogel commented 1 month ago

this is already automatically by Realtime.Database.detect_ip_version/1 and we already run it in production with IPv6

is your use case not covered by this?

Right, that only buys part of IPv6 support as described above: That detection is also needed when setting the socket-options for the Realtime.Repo. As written above, I got an :nxdomain in a pure IPv6 environment without these changes.

filipecabaco commented 1 month ago

oh got it! what do you think of making an explicit check for the repo?

e.g.

environment variable determining that the root db will be IPV6 true / false and use that to set things? Less code and easier to understand what is happening

tenants required to be more dynamic but the base database should be more "set in stone"

filipecabaco commented 1 month ago

we'll also need to update the mix.exs file to bump up the version 👀

tvogel commented 2 weeks ago

we'll also need to update the mix.exs file to bump up the version 👀

How do you handle the versions? I have updated it before but obviously, it's a race vs. other PRs. How to proceed?

filipecabaco commented 1 week ago

we had a couple of tricky weeks, hopefully after some of the pending PRs are tackled I will grab this and merge it myself. I hope to do it within a week

sorry for the inconvenience 😞 just really intense weeks overall