GeniusesOfSymfony / WebSocketBundle

:part_alternation_mark: Websocket server for Symfony applications (powered by Ratchet), includes a Autobahn.JS based JavaScript client
MIT License
609 stars 140 forks source link

TopicRegistry is empty #203

Closed Leggy7 closed 7 years ago

Leggy7 commented 7 years ago

Trying to subscribe to a channel, I get the following error

websocket.ERROR: Connection error occurred Topic acme.topic does'nt exist in [ ] in C:\Users\utente\Documents...\vendor\gos\web-socket-bundle\Server\App\Registry\TopicRegistry.php line 43

I'm following the basic implementation and I cna't really find out what's causing this problem.

my services.yml:

services:
    acme_hello.topic_sample_service:
        class: AppBundle\Topic\AcmeTopic
        tags:
            - { name: gos_web_socket.topic }
        requirements:
            idClass:
                pattern: '\d+'

    acme_hello.rpc_sample_service:
        class: AppBundle\Rpc\AcmeRpc
        tags:
            - { name: gos_web_socket.rpc }

my routing.yml

acme_topic:
    channel: acme/channel
    handler:
        callback: 'acme.topic'

acme_rpc:
    channel: sample/{method}
    handler:
        callback: 'acme.rpc'
    requirements:
        method:
            pattern: "[a-z_]+"

my config.yml

# Web Socket Configuration
gos_web_socket:
    server:
        port: 8080        
        host: 127.0.0.1  
        router:
            resources:
                - '@AppBundle/Resources/config/pubsub/routing.yml'
    pushers:
        wamp:
            host: 127.0.0.1
            port: 8080

and the client is:

var websocket = WS.connect("ws://127.0.0.1:8080");
    console.log(websocket);
    websocket.on("socket/connect", function(session){
      //the callback function in "subscribe" is called everytime an event is published in that channel.

      session.subscribe("acme/channel", function(uri, payload){
          console.log("Received message", payload.msg);
      });
      session.publish("acme/channel", "This is a message!");
    })

    websocket.on("socket/disconnect", function(error){
        console.log("Disconnected for " + error.reason + " with code " + error.code);
    })

Is there a reason based on this code for I would get an empty set in the TopicRegistry?

Leggy7 commented 7 years ago

Actually I should have missed something in the confiuguration. Importing the demo project worked it out.

Sorry