websocket php ratchet with server vps 2 from hostinger using centos operation

Viewed 16
  1. hello all im try to make chat as real time im used websocket with php ratchet packege and this my code : in my file server.php this code

    use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; use MyApp\Chat;

    require dirname(__DIR__) . '/rat/autoload.php';
    
    $server = IoServer::factory(
        new HttpServer(
            new WsServer(
                new Chat()
            )
        ),
       8000
    );
    
    $server->run();
    

also my secend file is a script js in message.php :

      var conn = new WebSocket('ws://localhost:8000');                
    conn.onopen = function(e) {
    console.log("Connection established!");
    };
  1. please what i should to do w://loclahost:8000 is correct ? or should i changed in my host name ? or domain name? or what

secend qution what i should use port i had searched in google but i find more article that telk about httpd i cant f ind my answers please

0 Answers
Related