ratchetphp / Ratchet

Asynchronous WebSocket server
http://socketo.me
MIT License
6.29k stars 748 forks source link

WSS ERR_CONNECTION_CLOSED #694

Open andreadompe opened 6 years ago

andreadompe commented 6 years ago

i currently have this configuration on my LIghtsail VPS

public function handle() {
    require '/opt/bitnami/apache2/htdocs/gestionaleCore/vendor/autoload.php';

    $loop = ReactLoop::create();
    $pusher = new Pusher;
    // In ascolto del web sever per fare un push ZeroMQ dopo una richiesta AJAX.
    $context = new ReactContex($loop);
    $pull = $context->getSocket(\ZMQ::SOCKET_PULL);
    $pull->bind('tcp://127.0.0.1:5553');
    $pull->on('message', [$pusher, 'toBroadcast'] );

    $webSock = new ReactServer('0.0.0.0:33000', $loop);
    $webSock = new SecureServer($webSock, $loop, [
        'local_cert'        => '/opt/bitnami/apache2/conf/server.crt', // path to your cert
        'local_pk'          => '/opt/bitnami/apache2/conf/server.key', // path to your server private key
        'allow_self_signed' => TRUE, // Allow self signed certs (should be false in production)
        'verify_peer' => FALSE
    ]);

   $webServer = new IoServer(
      new HttpServer(
        new WsServer(
          new WampServer(
            $pusher
          )
        )
      ),
      $webSock
    );
    $this->info('Run handle SSL');
    $loop->run();
  }

From my javascript application i use this code

<body>
  <script src="autobahn.min.js"></script>
  <script>
    var conn;
    function onConnect(session) {
      console.log('connect!');
    }
    function onDisconnect(code, reason, detail) {
      console.log('disconnect!', code, reason, detail);
    }
    var configuration = {
      'maxRetries': 60,
      'retryDelay': 4000,
      'skipSubprotocolCheck': true
    }
    conn = new ab.connect('wss://[DOMAINNAME]:33000', onConnect, onDisconnect, configuration);
  </script>
</body>

on my firewall i've opened the port 33000

but every time i test my script i get this error on javascript console

WebSocket connection to 'wss://[DOMAINNAME].it:33000/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

Please i need help. Best regards

mbonneau commented 5 years ago

@andreadompe This could be caused by many issues. What troubleshooting have you tried?