Skip to content

The service ".service_locator.VS38E50" has a dependency on a non-existent service "Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher". #456

@ViktorieTrungerova

Description

@ViktorieTrungerova

services.yml

gos_web_socket:
    server:
        port: 8888        # The port the socket server will listen on
        host: 127.0.0.1   # The host ip to bind to
        router:
            resources:
                - '%kernel.project_dir%/config/pubsub/routing.yaml'
    client:
        firewall: [api, login, dev, main] # Can be an array of firewalls
        session_handler: 'session.handler.pdo'
    pushers:
        wamp:
            enabled: true # Flag to enable this pusher
            host: 127.0.0.1 # This will probably be the same as your `gos_web_socket.server.host` value
            port: 80 # This will probably be the same as your `gos_web_socket.server.port` value
            ssl: false # Flag to enable SSL connections to the websocket server, default false
            origin: null # The origin domain for the pusher, default null (if origin checking is enabled on your websocket server, this value must be allowed)

MyController.php

<?php

namespace App\Controller;

use App\Repository\LanguageRepository;
use App\Repository\ProfileRepository;
use App\Repository\Repository;
use App\Websocket\WsNotificator;
use Gos\Bundle\WebSocketBundle\Pusher\PusherInterface;
use Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Cache\CacheInterface;

/**
 * @Route("/api/language", name="language_api")
 */
class LanguageController extends BaseEntityController {

	/**
	 * @Route("/", name="default", methods={"GET"})
	 */
	public function defaultAction(Request $request): ?JsonResponse
	{

		/** @var PusherInterface $pusher */
		$pusher = $this->get('gos_web_socket.pusher.wamp');
		$pusher->push(['msg' => 'hello'], 'chat.topic');
		var_dump('ok');
		die;
	}

	public static function getSubscribedServices()
	{
		return array_merge(
			parent::getSubscribedServices(),
			[
				'gos_web_socket.pusher.wamp' => WampPusher::class,
			]
		);
	}

}

When I have method getSubscribedServices in my controller and clear cache I get following error:

The service ".service_locator.VS38E50" has a dependency on a non-existent service "Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher".

Missing something in my config?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions