geniusesofsymfony / websocketbundle Goto Github PK
View Code? Open in Web Editor NEW:part_alternation_mark: Websocket server for Symfony applications (powered by Ratchet), includes a Autobahn.JS based JavaScript client
License: MIT License
:part_alternation_mark: Websocket server for Symfony applications (powered by Ratchet), includes a Autobahn.JS based JavaScript client
License: MIT License
I'm facing an issue with the server when user roles are stored in a database :
PHP Fatal error: Call to a member function toArray() on a non-object
in [...]/Entity/Users.php on line 308 [2015-08-15 23:44:39]
php.CRITICAL: Fatal Error: Call to a member function toArray() on a
non-object
{"type":1,"file":"[..]/Entity/Users.php","line":308,"level":-1,"stack":[]}[Symfony\Component\Debug\Exception\FatalErrorException] Error:
Call to a member function toArray() on a non-object
So I have digged into the code and the error is here :
File [Client\Auth\WebsocketAuthenticationProvider.php] : 119
$user instanceof UserInterface ? implode(', ', $user->getRoles()) : array()
If roles are set in a database (as explained in the Symfony doc), Symfony will fail to fetch the roles with $user->getRoles(); if roles are added to the user serialize, it will fail due to a bug apparently introduced in serialize() in PHP 5.4, and I didn't manage to get around it using json_encode / decode trick.
However, it is possible to easily retrieve the user roles from the token :
$roles = $token->getRoles()
A simple fix could be to remove the user roles display, but I don't know if roles are used elsewhere
Otherwise great bundle, thank you 👍
Hi. I will try get a fos user entity in my topic. I did put security context in argument, but this context is not related with fos?
//My topic definition
...
class JoaoImTopic implements TopicInterface
{
private $context;
public function __construct(SecurityContext $securityContext){
$this->context= $securityContext;
}
...
}
//My service definition and config:
services:
pdo:
class: PDO
arguments:
dsn: mysql:host=127.0.0.1;port=null;dbname=informatico-madrid
user: %database_user%
password: %database_password%
calls:
- [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
public: false
arguments:
- "mysql:dbname=informatico-madrid"
- %pdo.db_options%
parameters:
pdo.db_options:
db_table: sessions
db_id_col: sess_id
db_data_col: sess_data
db_time_col: sess_time
db_lifetime_col: sess_lifetime
db_username: %database_user%
db_password: %database_password%
framework:
...
session:
# handler_id set to null will use default session handler from php.ini
#handler_id: ~
handler_id: session.handler.pdo
...
gos_web_socket:
server:
port: 8080 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
router:
resources:
- @JoaoImWebBundle/Resources/config/pubsub/routing.yml
client:
firewall: main #can be an array of firewalls
session_handler: @session.handler.pdo
topics:
- @joaoim_webbundle.topic_sample_service
doctrine_cache:
providers:
redis_cache:
redis:
host: 127.0.0.1
port: 6379
database: 3
websocket_cache_client:
type: redis
alias: gos_web_socket.client_storage.driver.redis
Since Ratchet doen't support SSL (wss) - does this bundle support SSL?
Thx in advance
I've registered the bundle in my Symfony application, and this is what I get when I try and run the server:
Fatal error: Declaration of Gos\Bundle\WebSocketBundle\Router\NullPubSubRouter::generate() must be compatible with Gos\Bundle\PubSubRouterBundle\Router\RouterInterface::generate($routeName, array $parameters = Array, $tokenSeparator = NULL) in /vagrant/code/vendor/gos/web-socket-bundle/Router/NullPubSubRouter.php on line 10
Call Stack:
0.0013 232760 1. {main}() /vagrant/code/app/console:0
0.2934 3508528 2. Symfony\Component\Console\Application->run() /vagrant/code/app/console:27
0.3376 3710992 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /vagrant/code/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
1.8473 6149040 4. Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() /vagrant/code/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:73
4.3955 18654640 5. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:111
4.3955 18654960 6. appDevDebugProjectContainer->getGosWebSocket_ServerCommandService() /vagrant/code/app/bootstrap.php.cache:2140
4.4054 18709560 7. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:2412
4.4054 18709848 8. appDevDebugProjectContainer->getGosWebSocket_EntryPointService() /vagrant/code/app/bootstrap.php.cache:2140
4.4104 18719736 9. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:2231
4.4104 18720040 10. appDevDebugProjectContainer->getGosWebSocket_Server_RegistryService() /vagrant/code/app/bootstrap.php.cache:2140
4.4171 18726680 11. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:2397
4.4171 18727064 12. appDevDebugProjectContainer->getGosWebSocket_Ws_ServerService() /vagrant/code/app/bootstrap.php.cache:2140
4.4605 18857208 13. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:6565
4.4605 18857592 14. appDevDebugProjectContainer->getGosWebSocketServer_WampApplicationService() /vagrant/code/app/bootstrap.php.cache:2140
4.5006 18947704 15. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:6584
4.5006 18948056 16. appDevDebugProjectContainer->getGosWebSocket_Topic_DispatcherService() /vagrant/code/app/bootstrap.php.cache:2140
4.5204 18996704 17. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:2427
4.5204 18997024 18. appDevDebugProjectContainer->getGosWebSocket_Router_WampService() /vagrant/code/app/bootstrap.php.cache:2140
4.5248 19015816 19. Symfony\Component\DependencyInjection\Container->get() /vagrant/code/app/cache/dev/appDevDebugProjectContainer.php:2330
4.5248 19016088 20. appDevDebugProjectContainer->getGosWebSocket_Null_Pubsub_RouterService() /vagrant/code/app/bootstrap.php.cache:2140
4.5249 19016376 21. spl_autoload_call() /vagrant/code/app/bootstrap.php.cache:2259
4.5249 19016448 22. Symfony\Component\Debug\DebugClassLoader->loadClass() /vagrant/code/app/bootstrap.php.cache:2259
4.5291 19029664 23. require('/vagrant/code/vendor/gos/web-socket-bundle/Router/NullPubSubRouter.php') /vagrant/code/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:153
The docs have several examples on how to publish a notification from Javascript but how is this done from PHP?
Is it using the Pushers such as the WAMP pusher service? I've been poking around the docs for ages now and it's really not clear.
Thanks
Hello, after update with pubsub, I change my code to send user id with subscribe not with every message.
My routing
acme_topic:
channel: chat/{room}/{token}/{user}
handler:
callback: 'chat.topic'
requirements:
room:
pattern: "\d+"
token:
pattern: "[A-Za-z0-9]+"
user:
pattern: "\d+"
wildcard: true
The user has wildcard, because for one room every has another.
The problem is that users subsribe to:
chat/30/8ad77e0b4d5c1f5d8b6d/2
and
chat/30/8ad77e0b4d5c1f5d8b6d/0
are not in the same room. They don't see the same messages.
Maybe I did sth wrong.
Thanks in advance. :)
Hello I'm trying to integrate the bundle in my project to use the real time notification. I need to get logged user to get information related to this user. I followed step by step the all configuration in the bundle but when I try to get the user using $user = $this->clientManipulator->getClient($connection) every time the function get me the anonymous user.
Here is my configuration.
GOS Configuration:
gos_web_socket:
server:
port: "%clank_port%" #The port the socket server will listen on
host: "%clank_host%" #The host ip to bind to
router:
resources:
- @SomeBundle/Resources/config/pubsub/routing.yml
shared_config: false
topics:
- @some.topic_test_service
client:
firewall: backend_secure_area
session_handler: @session.handler.pdo
storage:
driver: @gos_web_socket.client_storage.driver.redis
decorator: @gos_web_socket.client_storage.doctrine.decorator
SNC Redis configuration
snc_redis:
clients:
ws_client:
type: predis
alias: client_storage.driver #snc_redis.client_storage.driver
dsn: redis://127.0.0.1/2
logging: %kernel.debug%
options:
profile: 2.2
connection_timeout: 10
read_write_timeout: 30
Doctrine Cache Configuration
doctrine_cache:
providers:
redis_cache:
redis:
host: 127.0.0.1
port: 6379
database: 3
websocket_cache_client:
type: redis
alias: gos_web_socket.client_storage.driver.redis
Session Handler configuration
pdo:
class: PDO
arguments:
dsn: mysql:host=%database_host2%;dbname=%database_name2%
user: %database_user2%
password: %database_password2%
calls:
- [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
arguments: [@pdo, {lock_mode: 0}]
GOS client Store driver configuration
gos_web_scocket.client_storage.driver.predis:
class: Gos\Bundle\WebSocketBundle\Client\Driver\PredisDriver
arguments:
- @snc_redis.client_storage.driver_client
My service
some.topic_test_service:
class: Backend\SomeBundle\Topic\SomTopic
arguments: [ @gos_web_socket.websocket.client_manipulator, @some.service]
Routing Channel configuration
some_topic:
channel: some/channel
handler:
callback: 'backend.some'
Topic class with periodic call
class SomeTopic implements TopicInterface, TopicPeriodicTimerInterface
{
/**
* @var TopicPeriodicTimer
*/
protected $periodicTimer;
/**
* @var ClientManipulatorInterface
*/
protected $clientManipulator;
/**
* @var SomeService
*/
protected $SomeService;
private $i;
/**
*
* param [ mixed $args [, $... ]]
* @param ClientManipulatorInterface $clientManipulatorInterface
* @param SomeService $transactionService
* @param ContainerInterface $container
* @internal param TokenStorageInterface $token
* @link http://php.net/manual/en/language.oop5.decon.php
*/
function __construct(ClientManipulatorInterface $clientManipulatorInterface,
SomeService $someService)
{
$this->clientManipulator = $clientManipulatorInterface;
$this->someService = $someService;
$this->i = 0;
}
/**
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
*/
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
$user = $this->clientManipulator->getClient($connection);
$topic->broadcast("Hello World ".$user);
}
/**
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
*/
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
//this will broadcast the message to ALL subscribers of this topic.
$topic->broadcast(['msg' => $connection->resourceId . " has left " . $topic->getId()]);
}
/**
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param $event
* @param array $exclude
* @param array $eligible
*/
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
{
/*
$topic->getId() will contain the FULL requested uri, so you can proceed based on that
if ($topic->getId() == "acme/channel/shout")
//shout something to all subs.
*/
$topic->broadcast([
'msg' => $event
]);
}
/**
* @return string
*/
public function getName()
{
return "backend.some";
}
/**
* @param Topic $topic
*
* @return mixed
*/
public function registerPeriodicTimer(Topic $topic)
{
$this->periodicTimer->addPeriodicTimer($this, 'some', 10, function() use ($topic){
$topic->broadcast("Hello World ".$this->i++);
});
//exist
$this->periodicTimer->isPeriodicTimerActive($this, 'some'); // true or false
//remove
$this->periodicTimer->cancelPeriodicTimer($this, 'some');
}
/**
* @param TopicPeriodicTimer $periodicTimer
*/
public function setPeriodicTimer(TopicPeriodicTimer $periodicTimer)
{
$this->periodicTimer = $periodicTimer;
}
}
When the websocket send the information about the user all time the user is anon-210954636255afb7a3535fe598094366 and I'm logged with other user.
Any idea??
It would be nice if someone could write a bit of documentation about the logic behind a private chat / notification system. Use Whatsup as a reference. Imagine that you want to build a simplified version of it.
Code is NOT strictly required, I think that what is really important is the LOGIC behind it:
These are just SOME examples.... just try to think about all the major issues you need to address when creating a basic private chat using a pub/sub system.
There are also some questions on Stackoverflow about this problem. For example:
http://stackoverflow.com/questions/28937843/symfon2-websocketbundle-simple-private-and-group-chat-database-schema-and
Hello, I am trying to set up pdo session for the bundle, my configurations are as follows -
pdo:
class: PDO
arguments:
dsn: mysql:host=%database_host%;dbname=%database_name%
user: %database_user%
password: %database_password%
calls:
- [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
public: false
arguments:
- @pdo
- { lock_mode: 0 }
But every time I am trying to start the websocket server, the following error occurs -
[PDOException]
You cannot serialize or unserialize PDO instances
I have searched for solution in the issues, and on the internet, but could not find any. Any kind of help would be really appreciated.
Actually im using ZMQ on my application making a call to a symfony controller and this save to db and push to socket for the user.
injecting doctrine on the pubstub is a good practice or wait for push server is better?
Hi,
When I try to launch the server in prod mode :
php app/console gos:websocket:server --env=prod
I get this error :
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The parameter "gos_pubsub_registered_routers" must be defined.
The same error when I try a
php app/console cache:clear --env=prod.
All is good for the dev environment.
Thx
Hi,
great works. Thanks!
I'm trying to integrate websockets with authenticated users and push notification to a specific user. Here my code:
onMyTopic class
protected $clientManipulator;
/**
* @param ClientManipulatorInterface $clientManipulator
*/
public function __construct(ClientManipulatorInterface $clientManipulator)
{
$this->clientManipulator = $clientManipulator;
}
/**
* @param ConnectionInterface $connection
* @param Topic $topic
*/
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
$user = $this->clientManipulator->getClient($connection);
$topic->broadcast(['msg' => $user . " has joined " . $topic->getId()]);
}
now I create a simple CLI command
protected function execute(InputInterface $input, OutputInterface $output)
{
$pusher = $this->getContainer()->get('gos_web_socket.wamp.pusher');
//push(data, route_name, route_arguments)
$pushMessage =$input->getOption('message';
$username = $input->getOption('username');
if ($username == '*') {
$pusher->push($pushMessage, 'myRoute');
} else {
$pusher->push($pushMessage, 'myRoute', ['username' => $username]);
}
}
But somethings go wrong. This message is pushed to every client.
Where is my mistake?
Thanks in advance.
v.
I like Assetic to dump files in a custom path (i.e. js/compiled/ - like in the Symfony docs) but I have a problem with the WebSocketBundle. I am overriding your GosWebSocketBundle::client.html.twig with my own that includes the "output" option, like this:
{% javascripts
'@GosWebSocketBundle/Resources/public/js/vendor/autobahn.min.js'
'@GosWebSocketBundle/Resources/public/js/gos_web_socket_client.js'
output='js/compiled/gos_websockets.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
However, now when I run assetic:dump the files are placed in TWO directories:
$ php app/console assetic:dump --env=prod --no-debug
Dumping all prod assets.
Debug mode is off.
14:18:06 [file+] /var/www/site/server/app/../web/js/6eb8fb0.js
14:18:06 [file+] /var/www/site/server/app/../web/js/compiled/gos_websockets.js
How do I stop your bundle from writing its javascript to my js/ folder?
This will be the next big challenge of next major release, adding STOMP protocol over websocket !
What is STOMP ?
STOMP is a simple text-orientated messaging protocol. It defines an interoperable wire format so that any of the available STOMP clients can communicate with any STOMP message broker to provide easy and widespread messaging interoperability among languages and platforms. STOMP wrap nicely Websocket protocol !
Concretly what that's change ?
That'll allow us to deal with ours Topic / RPC via Messaging queue system like RabbitMQ, ActiveMQ, in fact all queue system wich support STOMP protocol !
Why ?
Mainly to handle high traffic easily by dispatching Topic/RPC process accross many consumers. You just have to run consumer from one or several server and the queue system will automatically dispatch message accross your consumer !
That'll not break the current websocket implementation, so if you want only use websocket without stomp that'll change noting. From developper POV I hope it will be really easy to use, by simply add a parameter on routing definition to define if Topic/RPC are handled via messaging queue system.
When including {{ ws_client() }}
Uncaught ReferenceError: module is not defined
What am I missing ?
I've followed the documentation for sharing the session between symfony2.6 and gos websocketbundle.
Unfortunately it doesn't work. OnSubscribe I'm stil seeing "anon-5asdfjadkja has joined acme/channel" instead of "Username has joined acme/channel".
I've updated my github "testing" repository with the latest changes. You can see everything there.
P.s. The PDO session in symfony seems to be working great. New sessions are successfully stored in the mysql table and no errors are displayed in the debug toolbar.
There is probably some error in my gos configuration or in the gos bundle itself.
Also, please note that (in Composer) using this line
"gos/web-socket-bundle": "~0.1"
i got an error about minimun-stability restriction.
I solved using
"gos/web-socket-bundle": "@dev"
Currently, I can't share event handlers between my Symfony application and the server I launch using gos:websocket
. I'm guessing something needs to sit between the two apps, probably something like ZMQ (look at the approach given in this tutorial).
However, as you are instantiating the server, I can't put in the React ZMQ bindings.
Is there a way to use ZMQ or something similar with your bundle?
Hello,
I am at Step 4 : Link channel & topic with pubsub router of the description installation of the WebSocketBundle and I get this error: Unrecognized options "channel, handler" under acme_topic.
I think it's a problem with pubsub, i created AcmeBundle/Resources/config/pubsub/routing.yml but what did you mean when you said register it in the websocket bundle configuration?
Hi @gittix09, have you plan to use the origin checker feature ? If yes i'm interested to have your feedback about it !
Thank you very much !
Hi!
I'm subscribed in a topic (chat/channel/room1, for exemple), is possible publish in other topic (chat/xpto) from inside this topic?
Thanks!!
Hi guys,
This bundle depends on gos/ratchet
and gos/ratchet-stack
, but gos/ratchet-stack
depends on cboden/ratchet
, so both of them are downloaded and autoloaded by composer, which results in conflicts.
What would be the way to fix this? Maybe replace completely cboden/ratchet
by gos/ratchet
?
I opened this issue here but it may be more appropriate in the ratchet-stack repository?
PS: Thank you for all your work, the improvements you made are awesome!
Refer to JDare/ClankBundle#41
Quick solution : $connection->send(new Frame($msg, true, Frame::OP_BINARY));
but this need to disable UTF-8 on server : $wsServer->setEncodingChecks(false);
Hey
I would like get the currently user from the connection object in the onSubscribe method of ChatTopic.
Plz can you say me where onSuscribe method is called and where is implemented your personnal connexionInterface object? :)
Logged in user is connected with WS without problem. But now I want to get username in client side. But if I publish using js, I only get the message. How can I get the username and other related information. I have tried to modify MyTopic class. But it seems topic method(onPublish) does not work in case I send message through js. Also, if I want to add some other information with message how can I do that?
Here is the code for client side:
var _WS_URI = "ws://{{ websocket_host }}:{{ websocket_port }}/";
var webSocket = WS.connect(_WS_URI);
webSocket.on("socket/connect", function(session){
session.subscribe("app/notification", function(uri, payload){
console.log("Received message ", uri, payload);
});
session.publish("app/notification", "I want to send more info including username with this message");
});
Hi
How performe à ws server close évent i read that ratchet have server callback passes on the constructor to be executed when the server close
How to use thé server to send and receive messages from clients because thé docs arent clear if i understand i will rewrite wampapplication file to add onmessage évent and rewrite thé service that call thé websocketserver ?
Tkx
First off, a fantastic and very interesting bundle.
I have been struggling with this issue for the past 12 hours now, could it be a bug. The server starts well and everything seems to work until I (re)load a page which has the {{ ws_client }} then my logs spit out.
php.CRITICAL: Fatal Error: Call to undefined function Gos\Bundle\PubSubRouterBundle\Matcher\dump()
framework:
...
session:
handler_id: snc_redis.session.handler
...
snc_redis:
clients:
default:
type: predis
alias: default
dsn: %redis_server%
sessions:
type: predis
alias: sessions
dsn: %redis_server%
logging: false
......
session:
client: sessions
prefix: sess
use_as_default: true
.....
gos_web_socket:
client:
session_handler: @snc_redis.session.handler
firewall: main
storage:
driver: @gos_web_socket.sessions.predis
decorator: ~
shared_config: true
assetic: true
server:
port: 1337
host: localhost
origin_check: false
router:
resources:
- @WebSocketsBundle/Resources/config/pubsub/routing.yml
........
services:
gos_web_socket.sessions.predis:
class: Gos\Bundle\WebSocketBundle\Client\Driver\PredisDriver
arguments:
- @snc_redis.cache
- %web_socket_server.client_storage.prefix%
Hello again !! Currently I'm trying also to implement functionality PeriodicTopic (which I find very interesting) I'm trying to integrate the functionality of this bundle with a consumer process using amqp-lib and RabbitMQ. This is to receive information from an AMQP queue and then send this information to a particular client using a TopicPeriodic (new functionality) so that client can see the queue information in real time. Is this possible ?. I would like to contribute to this effort. Thank you very much and greetings.
At Step 4:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "web_socket_server" under "gos_web_socket"
Note: In the same Symfon2 project I tried removing Gos Bundle and installing Clank Bundle..... Clank bundle works. The server was launched successfully.
Hello before this commit when there was some error in topic(e.g. undefineded index in array), server crashed and showed the error. Now nothing is showed, just brodcast method doesnt' work. What does it mean forwarded into websocket? Cos i see nothing in console. Did you add automatic brodcast message that we send to the websocket? Can I turn off it?
Hi,
I'm trying to count users in each room;
For example i got room1&room2:
chat/channel/room1
chat/channel/room2
Now i want on my listpage, the available user in each room.
is this possible??
Thanks!!
This issue is a reminder to replace SecurityContextInterface with corresponding alternatives in the following two classes:
Gos\Bundle\WebSocketBundle\Client\Auth\WebsocketAuthenticationProvider
Gos\Bundle\WebSocketBundle\Event\ClientEventListener
Security context is deprecated since 2.6:
http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements
Meanwhile, the use of the bundle causes two warnings in the profiler:
Hi,
I am trying to connect to the websocket server using the example code in the wiki. But I get the error
Call to a member function save() on a non-object in ClientStorage.php on line 97
Which must means that the driver is null even though I think I configured it.
Here is my services.yml
pdo:
class: PDO
arguments:
dsn: mysql:host=%database_host%;port=%database_port%;dbname=%database_name%
user: %database_user%
password: %database_password%
calls:
- [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
arguments: [@pdo, {lock_mode: 0}]
gos_web_socket.client_storage:
class: Gos\Bundle\WebSocketBundle\Client\ClientStorage
arguments:
- %web_socket_server.client_storage.ttl%
- @?monolog.logger.websocket
app.blinks_topic_service:
class: AppBundle\Topic\BlinksTopic
tags:
- { name: gos_web_socket.topic }
arguments:
- @gos_web_socket.websocket.client_manipulator
gos_web_scocket.client_storage.driver.predis:
class: Gos\Bundle\WebSocketBundle\Client\Driver\PredisDriver
arguments:
- @snc_redis.cache
And here is the config.yml
doctrine_cache:
providers:
redis_cache:
redis:
host: 127.0.0.1
port: 6379
database: 3
websocket_cache_client:
type: redis
alias: gos_web_socket.client_storage.driver.redis
snc_redis:
clients:
cache:
type: predis
alias: cache #snc_redis.client_storage.driver
dsn: redis://127.0.0.1/2
logging: %kernel.debug%
options:
connection_timeout: 0
read_write_timeout: 30
gos_web_socket:
server:
port: 8080 #The port the socket server will listen on
host: 127.0.0.1 #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
storage:
driver: @gos_web_socket.client_storage.driver.predis
decorator: @gos_web_socket.client_storage.doctrine.decorator
Thanks
Hello. I want to connect to serwer from this bundle through WampSharp.
const string serverAddress = "ws://domaincoml:8080/";
DefaultWampChannelFactory channelFactory =
new DefaultWampChannelFactory();
IWampChannel wampChannel =
channelFactory.CreateJsonChannel(serverAddress, "realm1");
wampChannel.Open().Wait();
I can connect, and I see it in GOS console. However, i have exception {"subprotocol doesn't match"}.
Any ideas?
thanks!
Hi!
How can I return to my view (client side) all clients subscribeds in my topic?
Can you help me @Prophet777 ?
Thank you!
Hello,
Where can I config the server with ssl ? I saw that link: ratchetphp/Ratchet#161
but i don't know where are the files which I have to modifie.
Is there a way to configure and start more then one ws server - each running on different port?
Regards
Hey. It's me again, i'm really sorry. :)
After update, all my code doesn't work. I reseted all to code from tutorial, I mean js and Topic class.
But i still have the same error and i don't know what to do.
Connection error occurred Notice: Array to string conversion in /vendor/gos/web-socket-bundle/Server/App/Registry/TopicRegistry.php line 46 {"connection_id":657,"session_id":"553cb0a9eae46","client":"anon-553cb0a9eae46"}
Hello,
i dont know if ist a real bug but in my cas ist realy annoying.
I try to to implement three diferent topics with differnet routes
router.yml
eventri_event_push_sub:
channel: notification/events/{event}
handler:
callback: 'eventri.subscribe.event.topic'
eventri_role_push_sub:
channel: notification/roles/{role}
handler:
callback: 'eventri.subscribe.role.topic'
eventri_user_push_sub:
channel: notification/users/{user}
handler:
callback: 'eventri.subscribe.user.topic'
but each time i try to connect to one route e.g. "eventri_role_push_sub" the first route "eventri_event_push_sub" matches.
This behavior also appears if i add the requirments to the parameter in the channel.
Thank you very much and greetings.
Hi, how are you. I wanted to ask how I can send messages from the server to a specific client using PeriodicFunctionsService. I need to send to the client monitoring in real time. The documentation explains that the injection of a TopicService be performed.But I do not understand how I can do it. Please could you show me some example of this? Thank you very much.
Hello, I have a question concerning of client manipulation. I use Symfony users (which implements the Symfony\Component\Security\Core\User\UserInterface interface), which works perfectly to obtain the user through the firewall. For obtain these users use the ClientManipulator that is defined in the bundle. But I need to find users using a different method to findByUsername or findByRoles (I wish I could do looking through another own attribute of the User class). How can I do?
First, I want to thank you for this awesome bundle. I wasn't able to set Clank but this one was pretty simple; although with the big help from #4
But how to deploy on live site? When I run gos:server, console is locked and I can't exit it without ctrl+c.
When the program is updated, how to stop previous gos:server and rerun it?
Hi, I have a multiple applications that would run pretty much the same code base on the same server. Is there a way to avoid launching a websocket server for each one? Having them on separate channels would not be a solution since the server would not be able to match the other routes.
Hello I try to share sesssion by this tutorial: https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/SessionSetup.md
My configuration:
# Web Socket Configuration
gos_web_socket:
server:
port: 8080 #The port the socket server will listen on
host: 0.0.0.0 #The host ip to bind to
router:
resources:
- @AppChatBundle/Resources/config/pubsub/routing.yml
client:
firewall: secured_area
session_handler: @session.handler.pdo
storage:
driver: @gos_web_socket.client_storage.driver.predis
decorator: @gos_web_socket.client_storage.doctrine.decorator
# Doctrine cache
doctrine_cache:
providers:
redis_cache:
redis:
host: 127.0.0.1
port: 6379
database: 3
websocket_cache_client:
type: redis
alias: gos_web_socket.client_storage.driver.redis
# SNC
snc_redis:
clients:
ws_client:
type: predis
alias: client_storage.driver #snc_redis.client_storage.driver
dsn: redis://127.0.0.1/2
logging: %kernel.debug%
options:
profile: 2.2
connection_timeout: 10
read_write_timeout: 30
ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58: The service "gos_web_scocket.client_storage.driver.predis" has a dependency on a non-existent service "snc_redis.cache".
I've installed SNC and Redis Bundle.
Hello. I've tried to add RPC(https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/RPCSetup.md) and I had error: Unrecognized option "router" under "gos_web_socket.server"
My config:
gos_web_socket:
server:
port: 8080 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
router:
resources:
- @AppChatBundle/Resources/config/pubsub/routing.yml
Hello. I'm really sor for a lot of question, but i promise it's last this week. Friday today, yes <3
I can send message to user who publish sth, by $connection->event($topic->getId(), ['msg' => 'lol']);
How can I publish his message only for some session iD not for all topic. Is it possible?
I am trying to use WebSocketBundle with IIS, i use the address ws://my.domain.com, it works fine with built-in server (Ratchet) in Ubuntu but IIS throws me a 403 (Forbidden) error, i supouse due to invalid URL, but i have tried a lot of possible ws:// URLs without not sucess.
Thanks,
I have a problem when trying to start the websocket server. I get the following error:
The service "gos_web_socket.router.wamp" has a dependency on a non-existent service "gos_pubsub_router.websocket".
I have installed the bundle PubSubRouter. What can give solution to this problem ?. I would appreciate your help very much.
My configuration for the bundle is:
gos_web_socket:
server:
port: 8080
host: 127.0.0.1
I try to implement your amazing Bundle in the SymfonyDemoApplication. While playing around with the session, following the "Session sharing and user authentication" from the docs, I recognize that the method ClientManipulator::findByUsername()
creates a "Fatal Error: Call to a member function getUsername() on a non-object" if ClientManipulator::getClient()
returns a string for an anonymous user like "anon-194574850455dec3c3984ce333658432".
Looking on the other methods, it seems that they are affected too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.