I’ve been struggling with this issue for hours, hopefully someone can help.
I have a UDP server and TCP server just for health status, inside the live logs I do get logs that the server does get bind to the correct host and port according to the docs. In my case, I have it bind to fly-global-services:2000 for UDP and 0.0.0.0:3000 for TCP. When deploying and starting the server, it logs. I’ve tried using fly-global-service and 0.0.0.0 for the UDP port.
[info] HTTP Server listening on 0.0.0.0:3000
[info] Server listening on fly-global-services:2000
I test sending messages using Packet Sender using a fly shared IPv4 IP and the port (2000) but it doesn’t seem to receive nothing, on the TCP side, that does work, I am able to go to my domain and get back data. Do UDP services only work on dedicated IP’s or do shared IP’s also work?
For more context, below is some code:
I use node:dgram for UDP so bind code looks something like this
server.bind(port.port, UDP_HOST, () => {
console.log(`Server listening on ${UDP_HOST}:${port.port}`);
return logger.warn({
success: true,
message: `Server listening on ${UDP_HOST}:${port.port}`,
status: 200,
});
});
TCP bind looks something like this (using http)
monitorServer.listen(3000, TCP_HOST, () => {
console.log(`HTTP Server listening on ${TCP_HOST}:3000`);
logger.warn({
success: true,
message: `HTTP Server listening on ${TCP_HOST}:3000`,
status: 200,
});
});
My fly.toml file looks like this
app = 'udp-server'
primary_region = 'lax'
processes = ['app']
[[services]]
protocol = 'udp'
internal_port = 2000
[[services.ports]]
port = 2000
[[services]]
protocol = 'tcp'
internal_port = 2000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[[services.ports]]
port = 2000
[[vm]]
size = 'shared-cpu-1x'