Z
Z
zagamay_ru2018-05-15 10:51:38
CentOS
zagamay_ru, 2018-05-15 10:51:38

How to run websocket on centos7 server?

Hi all!
I ran into a problem, on the project I raised websockets using Ratchet, took port 8888, everything is fine on the local machine, started the daemon and javascript calmly accesses this port via ws://site.ru/online.
But when I uploaded everything to the server (Centos 7), then in js I get the following error:

WebSocket connection to 'ws://site.ru/online' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I have vestacp, I have prescribed rules for iptables: ACCEPT 0.0.0.0/0 8888 tcp
Additionally, I have registered access to this port with the hoster.
I even tried disabling the firewall with iptables.
In processes the demon is twisted.
But I still get this error...
Once I tried to raise web sockets on debian and it was enough to register them in iptables and everything worked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zagamay_ru, 2018-05-15
@zagamay_ru

I found a solution, in general, do not use the ratchet example on github https://github.com/ratchetphp/Ratchet,
There is another example of raising a websocket on the off site

$server = IoServer::factory(
                new HttpServer(
                    new WsServer(
                        new $server
                    )
                ),
                $port
            );

            $server->run();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question