WebSocket Server works but not WampServer

Visto 259 veces
Saltar al primer mensaje no leído

Saurabh Machave

no leída,
25 oct 2015, 0:08:5125/10/15
a Ratchet
Hello,

First, I tried Ratchet using a WsServer and it worked perfectly. Then I was trying the WampServer but that did not work as expected. The connection opened, but the publish did not work. I tried with Autobahn.js and Wampy.js with no luck. With Autobahn, the connection kept on opening and closing rapidly and with Wampy.js it just stayed open and nothing happened.

Here is my server configuration:

<?php

require 'vendor/autoload.php';
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use Ratchet\Wamp\WampServer;
use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;

class PubSub implements Ratchet\Wamp\WampServerInterface {
   
   
public function onPublish( Ratchet\ConnectionInterface $conn, $topic, $event,
    array $exclude
, array $eligible ) {
        echo
"published\n";
   
}
   
   
public function onCall( Ratchet\ConnectionInterface $conn, $id, $topic, array $params ) {
        echo
"called\n";
   
}
   
   
public function onSubscribe( Ratchet\ConnectionInterface $conn, $topic ) {}
   
   
public function onUnSubscribe( Ratchet\ConnectionInterface $conn, $topic ) {}
   
   
public function onOpen(Ratchet\ConnectionInterface $conn) {
        echo
"opened\n";
   
}
   
public function onClose(Ratchet\ConnectionInterface $conn) {
        echo
"closed\n";
   
}
   
public function onError(Ratchet\ConnectionInterface $conn, \Exception $e) {
        echo
"error\n";
   
}
   
}


$memcache
= new Memcached;
$memcache
->addServer('localhost', 30024);

$server
= IoServer::factory(
   
new HttpServer(
       
new WsServer(
           
new SessionProvider(
               
new WampServer (
                   
new PubSub()
               
), new Handler\MemcachedSessionHandler($memcache)
           
)
       
)
   
),
   
30024
);

$server
->run();
   
?>



As for the client Javascript, I used the sample scripts on their github pages.

Regards,
Saurabh

Saurabh Machave

no leída,
25 oct 2015, 8:51:4525/10/15
a Ratchet
I realized what went wrong. I was trying WAMP v2 clients with Ratchet. I tested a little with Autobahn for WAMP v1 and it worked!
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos