How to access Ratchet over https?
I have a web app in which I used ratchet websocket to make chat. when i deployed it on server it does work on HTTP but when i enabled HTTPS(ssl) it gave me an error. websocket connection failed.

```map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}


upstream websocket {
    server 127.0.0.1:8090;
}



server {
 
root /var/www/html/Example/public;

index index.php index.html;
 
server_name Example.com;
 
      error_log /home/ubuntu/error.log;
      access_log /home/ubuntu/access.log;

      client_max_body_size 10M;
      client_body_buffer_size     32k;
      client_header_buffer_size   8k;
      large_client_header_buffers 8 64k;
      fastcgi_buffers 16 16k;
      fastcgi_buffer_size 32k;
      proxy_buffer_size   128k;
      proxy_buffers   4 256k;
      proxy_busy_buffers_size   256k;


location / {

try_files $uri $uri/ /index.php?$query_string;
}

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 600s;
        proxy_send_timeout 600s;
              
}
 
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
# With php-fpm (or other unix sockets);
}

location ~ /\.(?!well-known).* {
        deny all;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/Example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/Example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}
server {
    if ($host = Example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


listen 80 ;
listen [::]:80 ;
 
server_name Example.com;
    return 404; # managed by Certbot
}
```



WebsocketServer.php File




```<?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()
    {
        $server = IoServer::factory(
            new HttpServer(
                new WsServer(
                    new SocketController()
                )
            ),
            8090
          
        );

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



Chat.Blade.php file



```<script>
var conn = new WebSocket('wss://stage.locumtenensconnections.com:8090/?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);
	

};
```



I m using supervisor and cheked that port is running and enabled even in firewall.
i tested it with netstat -tunl and telnet it.

Error which i m getting on web are :
WebSocket connection to 'wss://Example.com:8090/?token=b0612c14e9f9f226bfd677033ca5b507' failed: 

I m at the end of implementing solutions from many git ratchet issues reports.
Can someone please help to resolve this?

