Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant establish connection to wamp with autobahn! #555

Closed
tsaritepe opened this issue Sep 12, 2017 · 7 comments
Closed

cant establish connection to wamp with autobahn! #555

tsaritepe opened this issue Sep 12, 2017 · 7 comments

Comments

@tsaritepe
Copy link

tsaritepe commented Sep 12, 2017

I want to use use RPC via autobahn to my ratchet wamp server. But i could not establish the connection.

My server side:

$server = new \Ratchet\App('localhost',3000);
       $server->route('', new WebSocketController,['*']);
       $server->run();

My Class:

use Ratchet\ConnectionInterface as Conn;
use Ratchet\Wamp\WampServerInterface;

class WebSocketController extends Controller implements WampServerInterface {
   public function onPublish(Conn $conn, $topic, $event, array $exclude, array $eligible) {
        $topic->broadcast($event);
    }

    public function onCall(Conn $conn, $id, $topic, array $params) {
        $conn->callError($id, $topic, 'RPC not supported on this demo');
    }

    // No need to anything, since WampServer adds and removes subscribers to Topics automatically
    public function onSubscribe(Conn $conn, $topic) {}
    public function onUnSubscribe(Conn $conn, $topic) {}

    public function onOpen(Conn $conn) {
        echo "opened";
    }
    public function onClose(Conn $conn) {
         echo "close";
    }
    public function onError(Conn $conn, \Exception $e) {
         echo $e;
    }
}

And the client side:

 var autobahn = require('autobahn');
 var connection = new autobahn.Connection({url: 'ws://localhost:3000'});
 connection.onopen = function (session, details) {
   console.log(sessions);
};


connection.onclose = function (reason, details) {
   console.log(reason);
   console.log(details);
}
connection.open();

Here what i get from autobahn console.log:
unreachable
{ reason: null,
message: null,
retry_delay: 1.7760546390824472,
retry_count: 1,
will_retry: true }
unreachable

{ reason: null,
message: null,
retry_delay: 2.883934737974839,
retry_count: 2,
will_retry: true }

and what i get from serve side console output
opened close opened close

Anyone can help???

@cboden
Copy link
Member

cboden commented Sep 13, 2017

What does the Network tab in debug tools show? Try making a basic WebSocket connection, does that connect?

@tsaritepe
Copy link
Author

According the search I did among issues, I should use autobahn 0.8.* since it doesnt support wamp v2. I could not install that version via npm. The problem was probably this. I solved it by using thruway.

Thanks.

@alcalyn
Copy link

alcalyn commented Sep 14, 2017

Yes it is, I do so. Autobahn 0.9+ implements wampv2, we have to use autobahn 0.8, and I also don't find it on npm. Instead I find wamp1, but I haven't tested it yet.

@quickshiftin
Copy link

Hi - Might I suggest putting some sort of disclaimer on the bottom of the push demo page? One's natural tendency when working with Javascript these days is to reach for libraries via npm. I personally wasted a good two hours trying to figure this out yesterday...

@KristianLake
Copy link

Hi, I have seriously been trying for days to get this stuff working, using different autobahns and ratchet php and thruway. Does anyone have a complete example of this? :)

@WyriHaximus
Copy link

@topproto If you use Thruway, use https://github.com/voryx/Thruway.js/ with it. Ratchet, when used with autobahn expects a version that supports WAMPv1, IIRC the current versions only support WAMPv2 at this point.

@hayden-t
Copy link

#655 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants