jdare / clankbundle Goto Github PK
View Code? Open in Web Editor NEWA Symfony2 Bundle for use with Ratchet WebSocket Server
License: MIT License
A Symfony2 Bundle for use with Ratchet WebSocket Server
License: MIT License
I know I can launch the server by issuing php app/console clank:server but that's less than ideal, sending it to the background does not work, any suggestion ?
I'm using clank bundle and I want to test if socket server is running without problem
I have set the configuration as follow :
# Clank Configuration
clank:
web_socket_server:
port: 8080 #The port the socket server will listen on
host: domain.com #(optional) The host ip to bind to
the port 8080 is open and tested
after adding the two js files : autobahn.min.js
and clank.js
I do the following :
var myClank = Clank.connect("wss://domain.com:8080"); // I use SSL
myClank.on("socket/connect", function(session){
//session is an Autobahn JS WAMP session.
console.log("Successfully Connected!");
})
myClank.on("socket/disconnect", function(error){
//error provides us with some insight into the disconnection: error.reason and error.code
console.log("Disconnected for " + error.reason + " with code " + error.code);
})
note that the server is already running with the command :
php app/console clank:server
the problem is I can't get the success message in my console.. When I stop clank server , it outputs the failure message.
I don't know what's happening please help me ..
Based on the simple fact that this repository is not maintained (the last commit goes back 2 years) I took the initiative to create a fork to continue the development.
What changes?
So if you are interested
Feel free to play with it and send PR ;)
Sorry for my bad english.
But when i install the minimum for starting the RPC method I have already a :
Unable to find that command
Ratchet can't find the methode addFunc in the service...
I'm in localhost with Symfony 1.6 with wamp so i don't understand why i have this problem
Well the title is really self descriptive.
Anyway to use clank bundle in a production environment in an optimized way? I was testing and after a while the process from the console starts to consume a lot of RAM.
Any suggestion/idea?
Regards.
I think I'm quite able to replace my current Pusher.com implementation with the ClankBundle based on the current documentation. Certainly because the frontend Javascript logic seems the same. Only difference seems to be the Server listener, right? We actually do have the feeling we're missing some points, so that is where this is about.
It would actually be really helpful for others if a page with documentation and best practices could be made with all steps needed to replace Pusher (or any other service oriented push-service) with the ClankBundle. Can some of you make a start with this, than I can add extra info when I'm done by following that sort of guide myself.
Where does the ClankBundle in basic differ from this? https://pusher.com/tutorials/html5_realtime_push_notifications
I need to implement the Push to an Existing Site feature mentioned in the Ratchet documentation.
However, I found no clues on how to accomplish this functionality using Clankbundle! Could you please demonstrate (preferably with code) how would one use ZeroMQ with Clankbundle?
Other than that keep up the terrific work ๐
Hello. I've just installed the bundle with provided instructions and I have an error:
"Warning: Illegal string offset 'name' in \vendor\jdare\clank-bundle\JDare\ClankBundle\Server\App\Handler\TopicHandler.php on line 97"
How can I fix this? Is this bundle currently working?
Hi,
I'm working on a project requiring a notification to be sent every time a user takes an action from within a controller. I know it's possible to send publish requests from frontend javascript using a session.publish(); call, but I'm hoping to achieve the same kind of functionality from a controller. (ie user takes an action -> Controller gathers a list of users needing to be notified and does some other functionality -> Controller sends a publish call to Notification Topic for each user -> Notification Topic sends an appropriate message to each user.)
Thanks for the great bundle,
Patrick
Hi,
how can i access a session that's currently opened on the connection?
Regards
Hi,
I can't find how to send binary data from a client to a web server through ClankBundle websockets. Blobs seem corrupted. Do you have a clue about this problem ?
I use Filereader Api from the javascript client and readAsBinaryString method to get blobs from a file.
Thanks.
Hi!, I'm trying to persist some entity in a RPC service, I have passed the entity manager and I'm able to make queries, so it's working, but when I try to persist some entity it don't work, I'm not getting any error, but the flush order never ends...
echo 'pre flush ';
$this->em->flush();
echo 'post flush '; // never shown
I believe I have some close error to this one, once I was trying to persist on a postpersist cycle event, but in this case I'm not getting any error, so I got no idea whats wrong... any idea?
I have set up the ClankBundle. I want to initialize session management so, I can have session object attached to the connections. I did what was suggested in the documentation. Added a service, attached it to framework session and clank handler. But when I run, php app/console clank:server
it throws an error:
My services.yml file:
services:
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
public: false
arguments:
- "mysql:dbname=%database_name%"
- { db_username: %database_user%, db_password: %database_password% }
kernel.listener.clank.client_event:
class: Acme\ChatBundle\EventListener\AcmeClientEventListener
tags:
- { name: kernel.event_listener, event: clank.client.connected, method: onClientConnect }
- { name: kernel.event_listener, event: clank.client.disconnected, method: onClientDisconnect }
- { name: kernel.event_listener, event: clank.client.error, method: onClientError }
My config.yml file:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
handler_id: session.handler.pdo
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ JDareClankBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
clank:
web_socket_server:
port: 8080 #The port the socket server will listen on
host: 127.0.0.1 #(optional) The host ip to bind to
session_handler: session.handler.pdo
topic:
-
name: "acme" #Important! this is the topic namespace used to match to this service!
service: "acme_topic"
It is to be noted that the session handler works fine with in-browser app. It sets and gets session as expected. It is also reflected by changes in the table.
Well, how to close a connection without reloading the page? F.e:
$(document).ready(function(){
clank.close();
});
Or something like that. Is it possible to close the connection (without reloading/closing browser )?
Regards
Hello,
I am trying to install this package with composer under Symfony v2.3.1 but it seems that is not working:
I saw the last modification in your composer but I'm not sure you merged them.
how to send message one to one?
if user A want to send a message to user B , just use $exclude exclude the other user resourceId or use $include to include user B's resourceId. Is it right ?
I got this error message when I tried it with ratchet 0.3
[UnexpectedValueException]
$request can not be null
Hi, I'm reading about this project in order to use the bundle in one of my own. It turns out that after I launch the server I open up developer console from my browser and:
var conn = new WebSocket('ws://localhost:8080');
conn.onopen = function(e) {
console.log("Connection established!");
};
after that I'm connected to the web server. Will you plan to add Ratchet's OriginCheck features as a config parameter in config.yml
file? Or some sort of security that relies in who can get a connection to the server?
Currently the bundle supports the Javascript client. What about also supporting the PHP Client as described in the example on http://socketo.me/docs/push
By requiring react/zmq": "0.2.*|0.3.*
it will get possible to let the Symfony application directly talk with Ratchet.
$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode(array('message' => 'this will be pushed to all clients'));
Hi.
I'm working around with the RPCs, and when I try to inject the security context and recover the current user, this is null
I've tried in a bunch of different ways, but I'm always back to the same point... someone was able to do this? Any idea?
Thanks.
I dont know, if this is not possible, or I don't find the solution.
I think from inside a function I can only access the calling ConnectionInterface, but e.g. if I want to create a chat, I need to broadcast the chat message to all other conections, too.
King regards, hice3000.
PS: If possible, I don't want to use topics.
Kindly let me know if this bundle is still maintained, so that If I choose to integrate it in any of my apps i don't have to maintain myself.
I am asking as there has not been any commits in 4 years and a dozen un-resolved issues.
Thanks
Hi,
Is it possible to broadcast something to a topic from a custom Event Listener Class. I can't find the way to do it :/
Exemple : I want to broadcast a message when a client is disconnected.
Thx
In documentation you state
"Try pairing up a Periodic function with a Custom Topic handler to perform actions on a set of clients connected to a certain topic."
I'm unable to find a way to broadcast a message from periodic in order to send message to connected clients.
Is there a way to connect to certain topic from php? (ideally in periodic class)
HI there,
I have tried the examples provided in docs, they work fine with Chrome and Firefox but not with IE-9.
I know IE-9 doesn't support WebSocket. Is this the reason?
Hi, I'm trying to access the session after following along with the "Session Sharing" documentation, but I'm running into issues trying to access session variables. Currently I get the error: "Call to a member function get() on a non-object". I'm passing the request service into the Topic constructor and accessing the session through "$request->getSession();", but it's not working. Btw, I'm using mongodb to store the session data. Any hints on how I can access the session from within the Topic?
Is there any simple way to connect and subscribe to topic from php script? not from client using js
I have server running and would like to subscribe to topic from controller of my app.
I did read a bit about zeromq but cannot use it while it require php extension.
I try like this but dont have any info from running server that client managed to connect nor subscribe:
$context = new \ZMQContext();
$subscriber = new \ZMQSocket($context, \ZMQ::SOCKET_SUB);
$subscriber->connect("tcp://127.0.0.1:8080");
$subscriber->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, "test");
pls help
btw do you know any good way to kill clank server and restart it while its being started using cron?
Hello. Please, help with some issue.
I have service for RPC calls with injected DoctrineRegistry and MongoDB Doctrine Registry (i think this is the reason, but not sure). So user calls to this service each 5 seconds. After ~ 1h working linux command top
shows, that php loads almost all CPU.
Can somebody explain what is the reason?
Thanks.
Problem 1
- Conclusion: remove symfony/symfony v2.5.0
- cboden/ratchet v0.2.0 requires symfony/http-foundation 2.1.* -> satisfiable by symfony/http-foundation[v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9].
i have a certain problem with my websocket functionality.
I have a header with 3 different areas, each with it's own template. My problem:
How can i use the opened session from area 1 in area 2 and 3.
var _CLANK_URI = "ws://{{ clank_host }}:{{ clank_port }}";
var myClank = Clank.connect(_CLANK_URI);
myClank.on("socket/connect", function(session){
//session is an Autobahn JS WAMP session.
( do something )
});
I call this every time i need to work with the websocket server, e.g. publish, subscribe and unsubscribe to topics.
There has to be a workaround to use 1 session for all areas, cuz now everytime an area gets updated via ajax a new session is opened, and after a few events i end up having the same message in my javascript console for 10 times (and more, depending on the amount of events..), just because of all those connections.
Any idea?
Regards
I'm trying to build a chat app on a website (private use only... just for learning purposes).
However, after reading the bundle documentation (which is great) I found myself with many questions.
Please refer to this StackOverflow question:
http://stackoverflow.com/questions/28937843/symfon2-clankbundle-simple-private-and-group-chat-database-shcema-and-logi
Symfony 2.3 was released today.
Would it be possible to update composer.json to allow this bundle to be installed in it?
When installing this bundle through composer I receive the following error messages:
Package guzzle/common is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/stream is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/parser is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/http is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Should bundle dependencies be updated?
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.