We have a long running task we are trying to execute in nestjs in a fly machine. The task might take from 10 - 30 minutes as its agent doing some work. Yesterday I encountered this issue from server and it happened while task was running well and was around 15 minutes mark:
network error: Post “https://psyro.fly.dev/api/sessions”: http2: server sent GOAWAY and closed the connection; LastStreamID=1, ErrCode=NO_ERROR, debug=“”
Any idea why I got this error, if its from any config?
you need to run the task in the background and allow the client to transparently reconnect, as long-running connections over the internet can break for any number of reasons (in this case it’s likely our proxy restarting for an update).
Hi, thank you for response. What we are doing is we have an api in nextjs, when this api is triggered we publish a message in upstash to be queued which actually triggers the api in fly machine. So its qstash/upstash making the connection to server in fly. Now I have seen alot of time not just during initial machine reboot but even when a task is in progress it returns 502 response code and the goaway response. Not sure if I should chane something here. This is the config:
[build]
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = ‘stop’
auto_start_machines = true
min_machines_running = 0 # Keep at 0 to save costs when idle
processes = [‘app’]
[http_service.concurrency]
type = “requests” # Better for web apps than “connections”
hard_limit = 25 # Allow more concurrent requests
soft_limit = 10 # Higher threshold before scaling
[[vm]]
cpus = 2 # 2 CPUs for faster video encoding
cpu_kind = “performance” # Dedicated CPUs, not shared
memory = ‘4gb’ # More RAM for video buffering
memory_mb = 4096