Inbound UDP not arriving

Trying to get inbound UDP working with this guide: Running Fly Apps On UDP and TCP · Fly Docs

Fly services

[[services]]
  internal_port = 443
  protocol = "tcp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

  [[services.ports]]
  port = "443"

[[services]]
  internal_port = 80
  protocol = "tcp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0

  [[services.ports]]
  port = "80"

[[services]]
  internal_port = 3478
  protocol = "udp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0

  [[services.ports]]
  port = "3478"

Golang code:

	uaddr, err := net.ResolveUDPAddr("udp", listenAddr)
	if err != nil {
		return err
	}
	s.pc, err = net.ListenUDP("udp", uaddr)
	if err != nil {
		return err
	}
	log.Printf("server listening on %v, localaddr: %v", listenAddr, s.pc.LocalAddr())

prints: server listening on fly-global-services:3478, localaddr: 172.19.12.187:3478

Listen loop:

	var buf [64 << 10]byte
	var (
		n   int
		ua  *net.UDPAddr
		err error
	)
	for {
		fmt.Printf("waiting for udp package\n")
		n, ua, err = s.pc.ReadFromUDP(buf[:])

(...)

Installed tcpdump and tried listening to eth0:

echo hello world | nc -w1 -u myapp.foo.bar 3478
oot@56833023b066e8:/app# tcpdump -i eth0 udp                                                                                                                    
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel

Region is NRT. Am I missing something here? I’m correctly binding to fly-global-services, which resolves to the IP that’s in /etc/hosts

Hey @KitchenNight

Make sure that you use dedicated IP address for the app - either IPv6 (free) if your network supports it, or dedicated IPv4 ($2/month). UDP is not supported over shared IP addresses.

Yup that was it, allocated a IPv4 and it immediately started working

This information is better added to the UDP docs, I couldn’t find any reference stating that this feature only works with dedicated IPs

Good point.

Also, I just realized I made a mistake in my comment. We don’t support UDP over IPv6, so only dedicated IPv4 can be used.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.