voryx/ThruwayBundle

publishing doesn't work

Closed this issue · 1 comments

I'm using Symfony 4.4
I created a project for testing and followed the example from the readme file.

I can publish to a topic from the browser and subscribe to it in symfony and see the results echoed to the terminal.

I can run an RPC call from the browser to a function in symfony without issue.

However, when I publish to a topic from symfony (one that I have subscribed to in the browser) nothing happens. I get no errors, I get nothing.

Here is my config:

voryx_thruway:
    realm: 'realm1'
    url: 'ws://127.0.0.1:9001' #The url that the clients will use to connect to the router
    router:
        ip: '127.0.0.1'  # the ip that the router should start on
        trusted_port: '9001'  # Bypasses all authentication.  Use this for trusted clients.
        port: '8081' # public facing port.  If authentication is enabled, this port will be protected

My service config:

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    Voryx\ThruwayBundle\Client\ClientManager:
        alias: thruway.client
        public: true

And my controller (I trigger the publish by going to route on the of the publishAction method):

<?php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Voryx\ThruwayBundle\Annotation\Register;
use Voryx\ThruwayBundle\Annotation\Subscribe;
use Voryx\ThruwayBundle\Client\ClientManager;

class TestController extends AbstractController
{
	/**
	 * @Register("com.example.add")
	 * @param $num1
	 * @param $num2
	 * @return mixed
	 */
    public function addAction($num1, $num2)
    {
        return $num1 + $num2;
    }

	/**
	 *
	 * @Subscribe("com.spellingbee.word")
	 * @param $value
	 */
	public function subscribe($value)
	{
		echo $value;
	}
	/**
	 * @Route("/publish")
	 * @param ClientManager $client
	 * @return Response
	 * @throws \Exception
	 */
	public function publishAction(ClientManager $client)
	{
		$client->publish('com.spellingbee.word', ['nice']);
		return new Response(
			'<html><body><h1>NICE!!</h1></body></html>'
		);
	}
}

Also, I made the "voryx.thruway.client.react_connector" service public--it was throwing errors.

Any help would be appreciated.
Thanks

I solved this by following @vasanth-kumar-m-y in #100