Conference(Room API) function as ASG

sangsoo

Member
Hello.
I want to configure Conference(Room API) in amazon ASG environment.

Test order.
1. Configure ASG with a.b.com (CNAME).
2. Run 5 WCS servers (EC2 Instance) on a.b.com (CNAME).
3. "Bill" joins a.b.com. An Invite link containing a.b.com will be created (*)
4. "'Steve" joins the Invite link. Two cases occur here.
=> Success, when "Steve" connects to the EC2 instance connected by "Bill"
=> Failure, when "Steve" connects to the other 4 EC2 instances that "Bill" has not connected

How can "Steve" get the WCS server address of the Ec2 Instance joined by "Bill" first?

Thank you.
 

Max

Administrator
Staff member
Good day.
Unfortunately, there's no perfect way to bypass load balancer or autoscaling group entry point. We cannot predict what server will be chosen when connecting to the enry point by CNAME.
You can get WCS IP address where room is created, by /connect REST hook handling, but:
1. To handle REST hooks using RoomApi, you should proxy all the requests and all the responses to the standard RoomApp backend application, or RoomApi will not work:
PHP:
$body = file_get_contents('php://input');
$incoming_data = json_decode($body, true);

switch($api_method) {
    case"connect":
        // Save sessionId
        saveSessionId($incoming_data['sessionId']);
        // POST /connect query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
    default:
        // POST any query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
}
header('HTTP/1.1 200 OK', true, 200);
header('Content-Type: application/json');
echo json_encode($response_data);

// Passing query to WCS default RoomApp
function postToRoomApp($method, $data_string) {
    // Here should be your WSC RoomApp address
    $wcs_url="http://wcs:8081/apps/RoomApp/" . $method;

    $response="";
    if( $curl = curl_init() ) {
        curl_setopt($curl, CURLOPT_URL, $wcs_url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json',                                                                           
                               'Content-Length: ' . strlen($data_string)));  
        $response = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if($http_code != 200) {
            ubnormalResponse($http_code);
        }
        error_log($response);
        curl_close($curl);
    }
    return($response);
}

function ubnormalResponse($code) {
    if ($code == 403) {
    header('HTTP/1.1 403 Forbidden', true, $code);
    } else {
    header(':', true, $code);
    }
    die();
}
You should get WCS IP to pass request from sessionId in this case, too:
Code:
///             client IP and port  WCS IP and port
"sessionId" : "/192.168.1.83:61936/192.168.1.39:8443-7a076e23-186e-4069-ac29-b6b379fe8d8d",
2. WCS IP in sessionId is private IP, so you need to know its external IP, and the server must be available from outside directly for client to connect.
3. You should pass WCS external IP from backend to client by some way, to correct invitation link.
So we do not recommend to use RoomApi in ASG environment.
 
Top