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

publishing doesn't work #102

Closed
s001dxp opened this issue Jan 6, 2020 · 1 comment
Closed

publishing doesn't work #102

s001dxp opened this issue Jan 6, 2020 · 1 comment

Comments

@s001dxp
Copy link

s001dxp commented Jan 6, 2020

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

@s001dxp
Copy link
Author

s001dxp commented Jan 6, 2020

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

@s001dxp s001dxp closed this as completed Jan 6, 2020
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

1 participant