Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

server2server integration and login/logout issues

Avatar

Level 3

Hi,

I'm using the recent php sdk to create a room and generate auth tokens.

Every time the user tries to login we run the following php code:

try {

    $rtc->createRoom($room, $template, true);

    $collection = 'UserManager';

    $rtc->subscribeCollection($room, $collection);

} catch (Exception $e) {

    // room already exists?

    log($e);

}

$session = $rtc->getSession($room);

$token = $session->getAuthenticationToken($secret, $userName, $userId, $userRole);

Transient room which prevents duplicate IDs:

  • A user can always login at the first time.
  • If the user logs out, waits more than 5 minutes and tries to login again, he always succeeds.
  • If the user logs out with cSession.logout() and tries to login again after less than 5 minutes it always fails.

        I'm getting the login event and the logout event immediately after that, both in the flash client and from the LCCS server2server hooks.

        In the php try/catch block I'm getting: exception 'RTCError' with message '403' in lccs.php:889

  • If the user tries to login again after less than 5 minutes he always succeeds.
  • I've tried to see if the room exists or not with the room console and $lccs->getRoomInfo($room) but I can't see a consistent behaviour.

        Sometimes the room is destroyed and sometimes not but the user still can't login after less than 5 minutes.

Non-transient room which allows duplicate IDs:

  • When a user logs out, the room sometimes disappears even though it is supposed to be a non-transient room.
  • The user is getting the login and right after that the logout event if trying to login again less than 5 minutes after the previous logout.

Any idea what could be wrong?

Thanks

2 Replies

Avatar

Employee

Not really sure of what you mean by "Non-transient room which allows duplicate IDs: When a user logs out, the room sometimes disappears". How do you know the room has disappeared ? Did you check in the Developer Portal and it's not there anymore ?

Regarding the 403, that's an authentication error. I am wondering if your authentication token (in AccountManager in the PHP code) becomes invalid.

Basically the authentication session on the server-side has an inactivity timeout of 15 minutes, so if you don't access our services for 15 minutes the authentication token expires and you'll start getting 403.

There are a couple of options here:

1) if you can set up an interval timer or cron-job like task (don't know if it's possible in PHP) you can "ping" our server every 10 minutes and keep the token alive.

2) if you get a 403 you should login again and retry the operation.

Avatar

Level 3

Yes, I checked in the room console and the room is not there. $lccs->getRoomInfo($roomName) also shows that the room is not there.

Every time the user tries to login, either on the first time or after he loged out, I'm authenticating, trying to create the room and generating a token:

$rtc = new RTCAccount($accountURL);

$rtc->login($account, $pass);

try {
    $rtc->createRoom($room, $template, true);
    $collection = 'UserManager';
    $rtc->subscribeCollection($room, $collection);
} catch (Exception $e) {
    // room already exists?
    log($e);
}
$session = $rtc->getSession($room);
$token = $session->getAuthenticationToken($secret, $userName, $userId, $userRole);

I can save the lccs session in cache and use a cron-job to ping your server but I don't understand why the above doesn't work.

Currently in dev I only have one php request that authenticate and talk to lccs.

If on the future I'll have several concurrent requests, is it possible that one request will invalidate the lccs session of another request when it authenticates?