Hi,
I've managed to create the ratchet server and create a front-end that communicates over websockets.
I'm currently using the php-cgi (phps internal server) to host the webserver like in the example, however I want the websocket portion to run on Apache (like my main website).
I can run it both by directly connecting to the php-websocket server and by using Apache to proxy to the php-server.
My issue is that I can't manage to get Apache to serve the web server. I'm using apache 2.4 and PHP 7.3.
My server code is essentially just like in the example:
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8080
);
$server->run();
And my Apache config is something like:
LoadModule fcgid_module modules/mod_fcgid.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
ProxyPass "/endpoint.php" "ws://127.0.0.1:php_server_port/endpoint.php"
ProxyPassReverse "/endpoint.php" "ws://127.0.0.1:php_server_port/endpoint.php"
I've tried changing the php_server_port to the regular apache http port but I'm not sure if there's something missing like the Upgrade connection message or if the Ratchet server is missing something?
Many Thanks.