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

onPush() function not getting hit after push from controller using ZMQ #159

Closed
sujit13666 opened this issue Jun 9, 2016 · 9 comments
Closed

Comments

@sujit13666
Copy link

sujit13666 commented Jun 9, 2016

Config.yml

gos_web_socket:
    topics:
      - @app.real_time.subscribe
      - @app.real_time.push
    server:
        port: 8000        #The port the socket server will listen on
        host: localhost   #The host ip to bind to
        router:
            resources:
                - @AppBundle/Resources/config/pubsub/routing.yml
    client:
        firewall: main #can be an array of firewalls
        session_handler: @session.handler.pdo
    pushers:
        zmq:
            default: true
            host: 127.0.0.1
            port: 8888
            persistent: true
            protocol: tcp

pubsub/routing.yml

real_time_push:
    channel: all/user
    handler:
        callback: 'app.real_time.push' #related to the getName() of your topic

services.yml

app.real_time.subscribe:
        class: AppBundle\RealTime\Subscribe
        arguments: [ @gos_web_socket.websocket.client_manipulator ]
app.real_time.push:
        class: AppBundle\RealTime\Push
        arguments: [ @gos_web_socket.websocket.client_manipulator ]

The following function is getting hit when client subscribes on this topic. I can see the text in the console.

Subscribe Class onSubscribe() : Subscribe.php

public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
    {
        var_dump("This user is subscribed");
    }

But when pushed via zmq from controller the onPush() function never got hit. I have already implemented TopicInterdace and PushableTopicInterface in Push.php.

Push Class onPush() : Push.php

public function onPush(Topic $topic, WampRequest $request, $data, $provider)
    {
        var_dump("Helloooooooooooooooooo0000000000");   
    }

Please can any one tell me where did I do wrong. Thanks in advance. Here is the controller

$pusher = $this->container->get('gos_web_socket.zmq.pusher');
//push(data, route_name, route_arguments)
$pusher->push(['my_data' => 'data'], 'real_time_push', ['username' => 'sujit']);
@sujit13666
Copy link
Author

@Prophet777 Please have a look. I am stuck for 2 days now.

@jjsaunier
Copy link
Contributor

Why do you segregate these services?

      - @app.real_time.subscribe
      - @app.real_time.push

subscribe and push are part of the same class, I think the problem is here.

@sujit13666
Copy link
Author

sujit13666 commented Jun 10, 2016

@Prophet777 Sorry for late response. Made a single class for both Subscribe and Push. Created following configuration but same problem.Subscribing is fine but onPush() is not working.

config.yml

gos_web_socket:
    topics:
      - @app.real_time.subscribe_and_push
      #  - @app.real_time.push
    server:
        port: 8000        #The port the socket server will listen on
        host: localhost   #The host ip to bind to
        router:
            resources:
                - @AppBundle/Resources/config/pubsub/routing.yml
    client:
        firewall: main #can be an array of firewalls
        session_handler: @session.handler.pdo
    pushers:
        zmq:
            default: true
            host: 127.0.0.1
            port: 8888
            persistent: true
            protocol: tcp

pubsub/routing.yml

real_time_subscribe_push:
    channel: all/user
    handler:
        callback: 'app.real_time.subscribe_and_push' #related to the getName() of your topic

services.yml

app.real_time.subscribe_and_push:
        class: AppBundle\RealTime\SubscribeAndPush
        arguments: [ @gos_web_socket.websocket.client_manipulator ]

SubscribeAndPush Class onSubscribe() : SubscribeAndPush.php

public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
    {
        var_dump("Subscribed..............."); //This is working like a charm
        // TODO: Implement onSubscribe() method.
    }

subscribed

SubscribeAndPush Class onPush() : SubscribeAndPush.php

public function onPush(Topic $topic, WampRequest $request, $data, $provider)
    {
        var_dump("PUSHED................."); //Never got hit
        // TODO: Implement onPush() method.
    }

Controller

$pusher = $this->container->get('gos_web_socket.zmq.pusher');
//push(data, route_name, route_arguments)

$pusher->push(['my_data' => 'data'], 'real_time_subscribe_push', ['username' => 'sujit']);

@sujit13666
Copy link
Author

and after hitting the controller, on the profiler the GOS/Websocket bundle icon appears with push message counts but still no print in console or client side. @Prophet777
push

@sujit13666
Copy link
Author

There is another thing. According to the docs-

Pusher event

When pusher send message or fail to send it, we dispatch event to allow you to plug your own logic.

  • Success : gos_web_socket.push_success
  • Fail : gos_web_socket.push_fail

Will give an Gos\Bundle\WebSocketBundle\Event\PushHandlerEvent where can access to the message and to the handler.

But on the profiler events these events never fired.

no_event

I added eventListeners. But there is no response. @Prophet777 please suggest what should I do.

@jjsaunier
Copy link
Contributor

Have you try with websocket pusher? (He use directly onPublish instead of onPush take care) Maybe windows is the problem with zmq

@sujit13666
Copy link
Author

sujit13666 commented Jun 10, 2016

Can you tell me which is recommended? I thought websocket pusher is not recommended due to latency. Can you send me the link of proper zmq library. I have downloaded from This Link. thanks @Prophet777
I am using php 5.5.12
BTW websocket pusher works like a charm. But I need to know which is recommended.

@sujit13666
Copy link
Author

sujit13666 commented Jun 13, 2016

Is there any way that this bundle support Wamp v2 ? If not can anyone redirect me to anything where I can use angular for autobahn js with Wamp v1 ?

AngularWamp is only for Wamp v2.

@Prophet777 Thanks in advance. And sorry for asking too many questions.

@DrLecteur
Copy link

I actually have the same probleme from the original poster.
OnPush() is not called from a controller, therefor the Push event in controller look ok.

I'm on Win10, using Wamp server, as the poster, so i guess ZeroMQ have issue with windows ?

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

3 participants