Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

358
Visualizações
Autobahn-js failes to connect to Ratchet Server (Wamp)

I've already checked plenty of questions and tutorials and I'm following the official documentation from socketme portal. I'm running this on XAMPP/Localhost.

Websocket works, when I'm not using the WAMP interface. Otherwise, it fails to connect and doesn't state any reason.

Error is: "app.js:6200 WebSocket connection to 'ws://localhost:8080/socket' failed: connection closed unreachable"

Server

$server = new \Ratchet\App('localhost', 8080);
$server->route('/socket', new WebSocketHandler, array('*'));
$server->run();

WebSocketHandler is a basic implementation of WampServerInterface and only includes the abstracted methods without any change.

On the client side, I'm doing the following to try a connection via autobahn-js:

           var connection = new Autobahn.Connection({

            transports: [{
                type: 'websocket',
                port: 8080,
                host: 'localhost',
                url: 'ws://localhost:8080/socket'
            }],
            realm: 'realm1'
        });

        connection.onopen = function(session) {
            app.content = app.content + `connected!`
        };

        connection.onclose = function(reason, details) {
            app.content = app.content + `onclose!`
        }

        connection.open();

I've done something wrong in this implementation, but I can't figure it out. I've tried avoiding the ->route approach and using the following vanilla approach:

$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new WampServer(
              new WebSocketHandler()
              )
        )
    ),
    8080
);

But, it didn't work.

Any help is much appreciated.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You need Autobahn.js 0.8.2 to connect it to Ratchet (WAMP v1) and it's a pretty old implementation and also ab 0.8.2 is extremely old.

You should navigate your work to Thruway. I tried doing it, but I couldn't find any custom implementation of Thruway RatcherRouter (onMessage, onOpen, etc.), therefore, I decided to do my own (pretty bad) implementation of Ratchet.

TL;DR: Switch to Thruway.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda