Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

345
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!