WebSockets with ratChet php does not work

0

I am currently studying websockets, and while trying to follow several examples found on the internet and on the website of ratChet I simply can not run the server, the terminal looks like this:

Here is the code for the example I used:

Chat.php

<?php
namespace MyApp;
require dirname(__DIR__) . '/vendor/autoload.php';
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class Chat implements MessageComponentInterface {
    public function onOpen(ConnectionInterface $conn) {
    }

    public function onMessage(ConnectionInterface $from, $msg) {
    }

    public function onClose(ConnectionInterface $conn) {
    }

    public function onError(ConnectionInterface $conn, \Exception $e) {
    }
}

chat-server.php

<?php
require dirname(__DIR__) . '/src/Chat.php';
use Ratchet\Server\IoServer;
use MyApp\Chat;

    require dirname(__DIR__) . '/vendor/autoload.php';

    $server = IoServer::factory(
    new Chat(),
    8080
    );

    $server->run();

I even thought it might be because of port 8080, but I am testing on my computer locally. What am I doing wrong?

    
asked by anonymous 05.01.2018 / 14:56

0 answers