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

Can't start server because of `non-existent service "security.token_storage"` #392

Closed reypm closed 5 years ago

reypm commented 5 years ago

After a fresh installation of the bundle using the composer require gos/web-socket-bundle which added the required classes to config/bundles.php and run the command php bin/console gos:websocket:server the following message pops up:

php bin/console gos:websocket:server

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86: The service "gos_web_socket.client_event.listener" has a dependency on a non-existent service "security.token_storage".

The version installed by the composer require were:

gos/pnctl-event-loop-emitter        v0.1.7             Pnctl event emitter for event loop
gos/pubsub-router-bundle            v0.3.5             Symfony PubSub Router Bundle
gos/web-socket-bundle               v1.8.13            Symfony Web Socket Bundle
gos/websocket-client                v0.1.2             WAMP client in PHP
mbabker commented 5 years ago

Admittedly it's been a while since I've run the 1.x code in production, but the dependency is removed in master (upcoming 2.0 release) via https://github.com/GeniusesOfSymfony/WebSocketBundle/commit/18ace24525d943de0347ffc09ff9b5d493124644. I think it can safely be removed in the 1.x branch as well since if I'm remembering the reason I went for that change correctly, the token storage can't actually be reliably used within the websocket process since it's a single long running process and the token in storage effectively gets changed on every client connection.

For 1.8.13, try removing these lines in the GosWebSocketExtension class, these lines in the WebsocketAuthenticationProvider::getToken() method, and these lines in the WebsocketAuthenticationProvider constructor and see what happens. That should effectively remove the dependency on the SecurityBundle services (note you still need symfony/security-core installed since the TokenInterface is used a bit).