Ratchet Session Syncronisation Poblem

839 views
Skip to first unread message

tmaa...@googlemail.com

unread,
Sep 12, 2014, 4:06:19 PM9/12/14
to ratch...@googlegroups.com

Hello Everybody,

I use ratchet with memcache session like descripted here: http://socketo.me/docs/sessions

I noticed the following:

1. Setting a session variable via HTTP Web Server
            
$session->set('uname', $uname);

2. Open new browser window and connect to websocket

3. Read the session data in onMessage

public function onMessage(ConnectionInterface $conn, $msg) {
    $conn
->Session->get("uname");
}

this works, the uname is correct.

4. change the session variable in window 1 or remove it
        
$session->remove('uname');
$session
->invalidate();

5. call onMessage again in second browser window (see step 3.)

the uname isset and has the same value as before.
It seems to be the case that the session update has not been commited to ratchet or to memcache.
I dont know how memcache works internaly but i thought the session object will syncronized to each instance.
This seems to be not the case. If i have multiple instances opened and i destroy the session in one of them then the session will not be destroyed in the other instances.

Is this the correct behaviour?
I searched for something like $session->commit(); but there is none.
It seems to be the case that the ratchet server loads the session data once on connect and after that the ratchet session object is independent from the http clients one.
Can you confirm that?




cboden

unread,
Sep 14, 2014, 2:06:52 PM9/14/14
to ratch...@googlegroups.com, tmaa...@googlemail.com
onOpen fetches the session data and it is stored in memory at that point. At any time during the connections life the calls are read from the data in memory. A re-write of the Session component is planned where you can re-fetch the data but currently you run the possibility of having stale data cached. 
Reply all
Reply to author
Forward
0 new messages