@rubys - thanks for your response. This is my setup:
The fly.toml seems to be correct, as the flyctl services list
reports:
PROTOCOL PORTS HANDLERS FORCE HTTPS PROCESS GROUP REGIONS MACHINES
TCP 80 => 6902 [HTTP] False app waw 2
TCP 443 => 6902 [TLS,HTTP] False app waw 2
TCP 88 => 6901 [HTTP] False app waw 2
Now, there are two php processes running two services:
php ratchet/server.php > ws.log &
php -S 0.0.0.0:6902 index.php
The ratchet server is initialized as below:
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
6901,
'0.0.0.0'
);
$server->run();
Now, when I ssh into the container’s console and run:
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: 0.0.0.0" -H "Origin: http://0.0.0.0" -H "Sec-We
bSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" http://0.0.0.0:6901
I’m getting correct response:
HTTP/1.1 426 Upgrade Required
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
X-Powered-By: Ratchet/0.4.4
…but when I do the same from my computer’s local terminal (of course, providing the correct application hostname and the external port 88
, I’m getting either this:
curl: (56) Recv failure: Connection reset by peer
or this:
curl: (52) Empty reply from server
So - addressing your advices:
- ws/wss - I’m not event that deep into testing - just a simple cURL test to see if the connection gets upgraded at least,
- there apparently is the websocket on local port 6901 as I can connect from containers console.
EDIT#1: Interesting - I have changed the ports in my fly.toml and set the port of main http service to something different than 80 (81 to be exact) and it is not working. Unfortunately, using this port for the webservice does not work either. I have also used different region - didn’t help. Any idea why changing the default port from 80 to 81 makes the service unavailable? Changing back to 80 fixes the issue (but websocket is not reachable in any case). Btw, I’m on the Hobby Plan with shared IP - does this make any difference?
EDIT#2: I start to suspect the problem with SSL. I have found the information, that for the .dev
domain the HTTPS is enforced. Now, as an experiment, I modified the part of my fly.toml concerning only the main www service:
[[services]]
protocol = "tcp"
internal_port = 8080
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[[services.ports]]
port = 443
handlers = ["tls", "http"]
[[services.ports]]
handlers = ["tls", "http"]
port = 8080
This should expose the service on internal 8080
to two external ports: 443
and 8080
. This works only for the default 443
but for the latter returns the SSL_ERROR_SYSCALL
when testing with cURL. Why is that?
EDIT#3 just to mention that my app is dockerized and work fine in a local environment.
EDIT#4 OK, after many hours of fighting with this, I managed to run the websocket service and bind it to the default HTTPS 443
port. This seems to indicate, that this is the only external port, that’s available and there is no way to use any other port, unless I’m missing something in my configuration or this is the limitation of the Hobby plan…
Any further clues what to check or look for?