I'm trying to create a video chat using ratchet with laravel and it worked fine on localhost but when I deployed it on an EC2 instance, it needed some configuration. First, I can access my app with HTTPS, it works fine. I can connect to my Ratchet WebSocket server via ws and HTTP but HTTPS requires wss and I can't figure out how to make it work. I've used ProxyPass since it seems to be the answer for most people : (etc/httpd/conf.d/ssl.conf)
ProxyPass /wss2/ ws://fake-domain.us-east-2.elasticbeanstalk.com:8181/
And my client side JS code : var socket = new WebSocket('wss://fake-domain.us-east-2.elasticbeanstalk.com/wss2/');
But this returns : 'Error during WebSocket handshake: Invalid status line' and it doesn't even change anything if I run my Ratchet server or not.
PHP code (I managed to put it in a laravel command so it's easier):
public function handle()
{
$server = IoServer::factory(
new WsServer(
new VideoController()
),
8181
);
$server->run();
}
I can telnet fake-domain.us-east-2.elasticbeanstalk.com 8181, it says it works. I saw that it could come from the apache version so I updated my apache and php version : php -v = 7.2.8 httpd -v = 2.4.34 I accept all traffic in the security groups and port 80, 443 and 8181 are open.
What am I missing? Thank's ;)
UPDATE : I figured out that I wasn't starting the socket server correctly, I forgot to put "sudo" before my command, but now it gives me another error:
UnexpectedValueException : $request can not be null
at /var/app/current/vendor/cboden/ratchet/src/Ratchet/WebSocket/WsServer.php:109
105| * {@inheritdoc}
106| */
107| public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) {
108| if (null === $request) {
> 109| throw new \UnexpectedValueException('$request can not be null');
110| }
111|
112| $conn->httpRequest = $request;
113|
UPDATE 2 :
I think I've just found the solution, I think I didn't integrate Ratchet correctly with Laravel and maybe the solution is here : https://gist.github.com/Mevrael/6855dd47d45fa34ee7161c8e0d2d0e88 I'm going to try tomorrow