ratchet websocket is working on HTTP but on https it is not working.
on HTTP it was working but on HTTPS it is not working.
chat:352 WebSocket connection to 'wss://stage.example.com:8080/?token=XXXXXXXXX9a00' failed:

my nginx server block
```
location /chat/ {
proxy_pass http://websocket/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
```
WebSocketServer.php


```<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Ratchet\Server\IoServer;

use Ratchet\Http\HttpServer;

use Ratchet\WebSocket\WsServer;
use React\Socket\Server;
use React\Socket\SecureServer;

use React\EventLoop\Factory;
use App\Http\Controllers\SocketController;


class WebSocketServer extends Command
{
     /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'websocket:init';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
       $loop   = Factory::create();
    $webSock = new SecureServer(
        new Server('0.0.0.0:8080', $loop),
        $loop,

// i have used with and without certs still it doesn't work.
        array(
            'local_cert'        => '/etc/letsencrypt/live/stage.Domain.com/fullchain.pem', // path to your cert
            'local_pk'          => '/etc/letsencrypt/live/stage.Domain.com/privkey.pem', // path to your server private key
            'allow_self_signed' => TRUE, // Allow self signed certs (should be false in production)
            'verify_peer' => FALSE
        )
    );
    // Ratchet magic
    $webServer = new IoServer(
        new HttpServer(
            new WsServer(
                new SocketController()
            )
        ),
        $webSock
    );
    $loop->run();

         //$server = IoServer::factory(
             //new HttpServer(
                 //new WsServer(
               //      new SocketController()
             //    )
           //  ),
         //    8080
          
       //  );

     //    $server->run();
    }
}
```


chat.blade.php


```

var conn = new WebSocket('wss://stage.example.com:8080/?token={{ auth()->user()->userId}}');

var from_user_id = "{{ Auth::user()->userId }}";
// var user_type = "{{ Auth::user()->userId }}";

var to_user_id = "";

var user_id="";



conn.onopen = function(e){

        console.log("Connection ok!");

        load_unconnected_user(from_user_id);

        load_unread_notification(from_user_id);

        load_connected_chat_user(from_user_id);


};
```

used certbot certificate to implement HTTPS on domain stage.example.com in my nginx server block

can someone plz help to resolve this?
I have applied all of the above configurations but still facing the issue.