Ruby TCP Server with SSL

Hi!

I’ve written a small TCP server with SSL support, and I’m having trouble configuring it through the fly.toml file. It should be bound to the port 8089.

This is what I’m getting when booting:

2023-02-09T19:42:17.204 app[c50f0836] mad [info] I, [2023-02-09T19:42:15.512703 #528] INFO -- : Starting RubyTAK::Server v0.0.1 on port 8089
2023-02-09T19:42:17.204 app[c50f0836] mad [info] /usr/local/lib/ruby/3.2.0/openssl/ssl.rb:527:in `accept': SSL_accept SYSCALL returned=5 errno=0 peeraddr=172.19.65.17:45158 state=before SSL initialization (OpenSSL::SSL::SSLError)
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/lib/ruby/3.2.0/openssl/ssl.rb:527:in `accept'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/server.rb:32:in `block in start'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/server.rb:31:in `loop'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/server.rb:31:in `start'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/server.rb:14:in `start'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/cli.rb:18:in `block (2 levels) in run'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/bundle/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/bundle/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/bundle/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/bundle/gems/commander-4.6.0/lib/commander/runner.rb:58:in `run!'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /usr/local/bundle/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from /app/lib/ruby_tak/cli.rb:35:in `run'
2023-02-09T19:42:17.204 app[c50f0836] mad [info] from ./exe/ruby_tak:7:in `<main>'

This is the branch I’m using: Comparing main...pu-fly · pusewicz/ruby-tak · GitHub

Any idea how this should be configured?

handlers = ["tls"]

If you handle TLS in your own app, you need to remove this line; with the tls handler, our proxy will handle TLS itself and serve a plaintext connection to your app.
This docs page might help as well: Public Network Services · Fly Docs

Same thing:

2023-02-09T20:47:09.204 app[9248f6cc] mad [info] /usr/local/lib/ruby/3.2.0/openssl/ssl.rb:527:in `accept': SSL_accept SYSCALL returned=5 errno=0 peeraddr=172.19.65.41:48682 state=before SSL initialization (OpenSSL::SSL::SSLError)
2023-02-09T20:47:09.204 app[9248f6cc] mad [info] from /usr/local/lib/ruby/3.2.0/openssl/ssl.rb:527:in `accept'

Massaged the code a bit and got it to work in the end.