Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

343
Vistas
WebSocket connection to failed:

After looking at too many stackeoverflow question i could not find any solution which solve my problem,

i develop application with ratchet websocket.me which is working in my local machine fine with WS//:localhost:8080 but its not working on live (VPS) server here below is the server configuration and requirements,

I am not sure what i am doing wrong look at below code snippet

SERVER CONFIGURATION

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName kosm.online
    ServerAlias www.kosm.online
    ServerAdmin webmaster@kosm.online
    DocumentRoot "/var/www/kosm"
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ProxyPreserveHost On
  ProxyPass /wss2/ wss://kosm.online:8080


Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/kosm.online/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/kosm.online/privkey.pem
</VirtualHost>
</IfModule>

CLIENT SITE WEBSOCKET JAVASCRIPT

var token = document.getElementById('userToken').value;
var socket = new WebSocket('wss://kosm.online:8080?token=' + token);
    socket.onclose = function(event) {
        console.log('connection close');
    };
    socket.onopen = function(event) {
        console.log("Connection established!");
        // socket.send('Hello Me!');
    };

HERE IS WEBSOCKET SERVER

require dirname( __FILE__ ) . '/vendor/autoload.php';
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Socket;

    $server = IoServer::factory(
        new HttpServer(
            new WsServer(
                new Socket()
            )
        ),
        8080
    );
    
    $server->run(); 

HERE IS COMPOSER.JSON

{
    "autoload": {
        "psr-4": {
            "MyApp\\": "app"
        }
    },
    "require": {
        "cboden/ratchet": "^0.4.3"
    }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda