Comments (11)
Before digging into this issue, I must verify something to avoid wasting time.
To make authentication working, you must share the cookie with the same host (you can with another, but in this case you must configure http server to make a proxy pass).
So, assuming you have your symfony2 application working under www.dummy.com
domain, symfony2 will produce a cookie for the current domain (you can configure it, but by default, he take the current host). From here if you create a websocket server like ws://localhost:8080
or ws://127.0.0.1:8080
that will not working ! Because cookie app is at www.dummy.com
and websocket is running at 127.0.0.1
, from 127.0.0.1 you can't see *.dummy.com cookies.
So we are unable to retrieve the session id corresponding to the current session wich contains the security context of current user.
So make sure your PHPSESSID is under the same domain than your websocket.
Here some screens :
In my example, sf application is running under www.dummy.com domain whereas my websocket is running under localhost. So that don't work.
I must have all under localhost or all under dummy.com.
Check this, try, and say me.
from websocketbundle.
New update: Still not working (look at the error in command prompt screenshot)
I'm using XAMPP and the web app has the following URL: http://localhost/myproject/web/app_dev.php/sock
I've also tried changing the gos_web_socket/client/firewall option in config.yml to "main" (instead of "secured_area") but that did not work.
For more info on my configuration see the "Testing...etc" repository in my Github account.
from websocketbundle.
Your error come from a miss configuration of PdoSessionHandler, please follow these instructions : http://symfony.com/fr/doc/current/cookbook/configuration/pdo_session_storage.html, you can also refer to my "lab project" to see configuration https://github.com/ProPheT777/real_time_bidirectional_notification-symfony2-redis-websocket-pubsub/blob/master/app/config/config.yml#L46
Your firewall is "main", see https://github.com/gittix09/TestingGosWebSocket/blob/master/myproject/app/config/security.yml#L52
from websocketbundle.
Great news!! With your help and a lot of luck... I got it to work!! Your bundle is truly amazing!!
I had already used the symfony documentation that you linked... what helped me the most was your config.yml file. I copied/pasted everything regarding PDO and adapted it.
This is the code I re-used from your file:
parameters:
pdo.db_options:
db_table: session
db_id_col: session_id
db_data_col: session_value
db_lifetime_col: session_lifetime
db_time_col: session_time
lock_mode: 0
services:
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, %pdo.db_options%]
I changed the name of the "sessions" table columns (to match the ones currently suggested in symfony docs).
Also I deleted port=%database_port%; because my default value was NULL and that was a problem for symfony.
Is all this code strictly necessary for PDO session handler to work (or is there anything I should remove to keep the code clean)?
from websocketbundle.
To keep code light, you can delete the following options :
db_table: session
db_id_col: session_id
db_data_col: session_value
db_lifetime_col: session_lifetime
db_time_col: session_time
They will automatically fallback to default values, you can found default values here : https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L86
Keep this option lock_mode: 0
to avoid problem with session locking.
from websocketbundle.
Very good!! I also managed to implement the entity manager in the topic handler class and do some test queries (like retrieving the user_id from the username...etc).
By the way, what is (approximately) the estimated time before you release some tutorials about:
- user notifications
- private chat (between two users)
- group chat (between three or more users)
I'm really excited to learn how to implement those features.
P.s. As always, thank you very much for this amazing bundle!!
from websocketbundle.
Currently i'm working on PubSubRouter https://github.com/GeniusesOfSymfony/PubSubRouterBundle who is an very important component for WebSocketBundle & NotificationBundle. The main goal is to remove this : https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Server/App/Dispatcher/TopicDispatcher.php#L74 and make clean definition of what channel is linked to what handler.
Today you can only handle a channel by the prefix. Tomorrow that' will look's lile :
websocket_user_channel:
channel: user/admin/{user_id}
handler: @service_to_my_topic
requirements:
username: \d+
wildcard: true
So i'm working on and I think I have at least one week of work just for this component. I also msut write documentation about it.
For real time notification (on which I work as) is stuck until PubSubRouter is not finished but he is near of the end. In the first time, I don't know if it will be "easy" to use out of box because he need's to understand the concept of pubsub and currently only work with redis pubsub, maybe later support zeromq pubsub but it's not currently planned. And I also need to create a JS Client for NotificationBundle, He will be written with AngularJS (I do not plan to do, I do not need).
I also plan to port NotificationBundle into micro services, wich implements RESTFull API to push & fetch from any another applications and get the real time through exposed websocket. I must dig into Docker before do that, and currently I do not have the need but I want to try :D
from websocketbundle.
Nice!!
But there are some sentences in your last message that are not clear to me.
Please correct me if I am wrong:
- I understand that right now you are working on the PubSubRouter and that you need the same PubSubRouter to complete the NotificationBundle.
- The NotificationBundle now works with Redis PubSub system but you plan on switching to the new PubSubRouter. Anyway, the NotificationBundle will be completed (and not abandoned) right? Proper documentation for this bundle will be written, right?
- When you say "JS Client", are you referring to the code necessary to establish the connection and receive the notification OR to the code that simply displays the received notification in the html page?
From your message, I undestand that you do NOT plan to create it. Is that right? If it is true, is there any open source JS client that is compatible (or a tutorial, or somewhere we can learn how to create a simple JS client)?
from websocketbundle.
Yeah sorry, my english is bad :D
First point : PubSubRouter is a unique bundle who will be used inside WebsocketBundle to handle Topic & Rpc dispatching in a better way. NotificationBundle will also use this bundle to bind logic behind channel (pusher & fetcher).
Second point : Redis PubSub and PubSubRouter are complementary, PubSubRouter will not replace Redis PubSub, Redis PubSub allow us to be faster, scallable and use as notification storage. Here an example of how it's work :
- I start websocket server (throught websocket bundle)
- I start redis pubsub server
- Client (via websocket) subscribe to his own channel + globale channel (notification/user/user1, notification/user/all)
- NotificationBundle expose a "NotificationCenter" $notificationCenter->push('notification:user:user1')
- NotificationCenter publish the message on redis pubsub server, we catch the message, look the channel, retrieve all pushers for this channel, and call each pusher. Example of pusher : WebSocketPusher : push the notification in the websocket, RedisPusher : We store the notification.
We can plug pusher like we want, if you want sotre your notification through mongoDB, just create a mongoDB pusher and plug it via PubSubRouter, and each channel can different pusherd.
Why use redis pubsub : When we are in Redis PubSub we are async (non blocking), we very fast, and redis allow to subscribe / publish with channel pattern (like notification:user:*)
Third point: Yeah client JS means front end notification part (not only the connection), but this will only be done with AngularJS because my front end work with it, and I do not plan to port the NotificationAngularJS to native or jQuey like library (because I do not need it from my side. If somebody want to do it, sure i'll accept). I don't think i'll make a tutorial to achieve this because it's useless. You just need to know how call the API (2 methods, push and fetch), and the real time part is achieve via Gos Websocket JS with a notification JS lib (like toaster or alertify for example).
In nutshell and just to be clear :
PubSubRouterBundle allow us to link channel like :
- Websocket channel (notification/user/1)
- Redis PubSub channel (notification:user:*)
With any handlers (topic/rpc for websocket, pusher for redis in my cases).
It's like an HTTP router, you link the URL with a controller, here is the same but with pubsub channel and handlers.
from websocketbundle.
Very good explanation!! Thank you very much.
Now I'm very excited to see the NotificationBundle completed ;)
P.s. The news about your bundle is spreading. Look here
http://stackoverflow.com/questions/24041277/bundle-for-notifications-in-symfony2/29086169#29086169
from websocketbundle.
Wow thank you for the positive feedback on stack overflow !
I think I also will make "a call" on ClankBundle to say I have fork, improve & maintain this lib and all request or improvement will be take in consideration, because actually all PRs are ignored and it's too bad.
from websocketbundle.
Related Issues (20)
- Connection auto closes right after first incomming message HOT 1
- Suggestion: Native TLS support HOT 5
- The service ".service_locator.VS38E50" has a dependency on a non-existent service "Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher". HOT 5
- How define route with parameter?
- After upgrading Symfony from 5.3.0 to 5.3.13, gos:wsb gives error when client attempts to subscribe to channel HOT 4
- Push Notifications from Server HOT 1
- Error using PdoSessionHandler with symfony 6 - "VirtualSessionStorage::start() must be compatible.." HOT 3
- Session Problem PDO HOT 5
- Error installing the bundle: Undefined array key "port" HOT 2
- Uncaught ReferenceError: GosSocket is not defined HOT 2
- Please provide documentation for using the symfony messenger component as a pusher HOT 2
- Update to support modern Autobahn version. HOT 8
- New authentication flow using JWT HOT 9
- Subscribe to topic on server HOT 2
- Connection in IPV6 HOT 1
- TopicPeriodicTimer doesn't see new connections
- TopicPeriodicTimer only registered for one Topic, wrongly cleared if any one Topic has zero connections HOT 1
- How can I send a message HOT 2
- error while installing (In GosWebSocketExtension.php line 276 Notice: Undefined index: port)
- The "Gos\Bundle\WebSocketBundle\Pusher\PusherRegistry" class is deprecated and will be removed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websocketbundle.