jnnks
April 7, 2023, 8:04am
1
I am having problems with UDP packets reaching my application and tried to follow the guide here: Running Fly.io Apps On UDP and TCP · Fly Docs
How can I find out the IP Address of the special interface “fly-global-services” in Elixir/Erlang? It is not included in :inet.getifaddrs
.
What am I doing wrong?
PS: There was a very recent post yesterday that covered a very similar topic. Unfortunately it was deleted, before I could read it again: Issues with elixir :gen_udp inbound connections
jnnks
April 7, 2023, 8:24am
2
I found a very helpful snippet on Github: link
I was using the wrong function:
{:ok, {172, 19, 76, 91}} = :inet.getaddr(~c"fly-global-services", :inet)
{:ok, sock} = :gen_udp.open(5000, [:binary, active: true, ip: {172, 19, 76, 91}])
Works fine and traffic comes through.
1 Like
To find the ip of fly-global-services this what I did.
def init(:ok) do
{:ok, addr} = :inet.getaddr('fly-global-services', :inet)
{:ok, socket} = :gen_udp.open(5000, [:binary, {:active, true}, {:ip, addr}])
{:ok, socket}
end
The other problem is that UDP doesn’t work with the share IPv4 not IPv6. I had to allocate an IPv4.
2 Likes
jnnks
April 7, 2023, 8:35am
4
Thanks for the quick reply! I appreciate it
Good to note the allocated IPv4 address as well.
1 Like
system
Closed
April 14, 2023, 8:36am
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.