I’m facing some challenges with configuring WebSocket and HTTP REST endpoints on Fly.io, and I could use some assistance. I’ve been trying to set up a deployment with the following requirements:
- WebSocket connections on port 3050 (
ws://mytest.fly.dev:3050
) for real-time communication. - HTTP REST endpoints on port 8080 (
http://mytest.fly.dev/heartbeat
) for regular API requests.
Unfortunately, I’ve encountered a few difficulties in getting this configuration to work properly. I successfully receive a 200 response from the REST endpoint, however, the WebSocket connection returns either socket hang up
or ECONNRESET
. Please see the TOML below:
app = "mytest"
primary_region = "lhr"
[env]
REST_PORT = "8080"
WS_PORT = "3000"
[[services]]
internal_port = 8080
protocol = "tcp"
[[services.ports]]
handlers = ["http"]
port = "80"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
handlers = ["tls", "http"]
port = "443"
[[services.tcp_checks]]
interval = 10000
timeout = 2000
[[services]]
internal_port = 3000
protocol = "tcp"
[services.concurrency]
hard_limit = 10
soft_limit = 5
[[services.ports]]
handlers = ["http"]
port = "3050"
[[services.ports]]
handlers = ["tls", "http"]
port = "443"
[[services.tcp_checks]]
interval = 10000
timeout = 2000
I’ve checked my local server code, and it works as expected when running locally and I can connect to the specified ports (3000 & 8080). However, once deployed on Fly.io, the issues arise. I suspect there might be some misconfigurations in my Fly.toml file that are causing these problems.