Use PHP WebSocket Ratchet online

0

I'm trying to use Ratchet to create WebSockets in PHP on a site I own. When I ran the tests ( localhost ) everything worked perfectly, but when I try to put it online, it does not run the connection. Reading more on the subject, I saw that it would be necessary to change ip to be the server's - or use the correct reference. Which led me to this final code:

var socket = new WebSocket('ws://meusite.com.br:8000');

But when I access the site, after a while, I get this message:

  

failed: Error in connection establishment: net :: ERR_CONNECTION_TIMED_OUT

The server file has this code:

require __DIR__ .'/../vendor/autoload.php';

use Ratchet\Server\IoServer;
use Ratchet\http\HttpServer;
use Ratchet\WebSocket\WsServer;

$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new Chat()
        )
    ), 2000, '0.0.0.0'
);
$server->run();

I'm using composer also for the Ratchet package management.

I do not know what might be happening to not have the connection or what I let pass, but this process is not working online, only in localhost .

Editing the question, and already adding the response to the comment, I have access SSH yes, even when I try to start the script as done in localhost

php bin/server.php

The SSH displays the following error:

  

Fatal error: Class 'Ratchet \ http \ HttpServer' not found in /bin/server.php on line 10

Note : The final application is not going to be a chat, I'm doing this just for following a tutorial. The goal is to only exchange messages to inform you that a new request has been made, or that a new service order has arrived, etc.

    
asked by anonymous 04.07.2016 / 19:17

1 answer

1

Switch:

use Ratchet\http\HttpServer;

By:

use Ratchet\Http\HttpServer;

Because this occurs:

In Windows the files are case-insentive when you run:

use Ratchet\http\HttpServer;

He usually finds this in Windows (see Http begins with the letter H in uppercase):

./src/Ratchet/Http/HttpServer.php

Like-unix systems, such as linux use the file system as case-sensitive, so the moment you use use Ratchet\http\HttpServer; it looks for this:

./src/Ratchet/http/HttpServer.php

But on the server the file looks like this:

./src/Ratchet/Http/HttpServer.php

They are different.

    
04.07.2016 / 19:42