Welcome, Guest
  • Author Topic: Problem with FMS and AMFPHP  (Read 4089 times)

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Problem with FMS and AMFPHP
    « on: 03/14/07, 06:49 »
    Thanks Jorge,
        Following your advice, I am posting here. We have downloaded the login tutorial given by you. We have set up the Flash, AMFPHP and FMS properly.

         First of all , I wish to mention that we are testing the application on the  localhost and there should be no issues popping like crossdomain.xml.

         We got 100 % success with Flash and AMFPHP for any examples we have tried till date. Login sample also works with Flash player as client. But with FMS as client, it just does not move by an inch. I got a simple trace() working in FMS. The entry gets into the the log file and (obviously) in the FMS console-> View Applications -> live log.
       
        A new application gets created properly. But the call to AMFPHP goes nowhere. So it is stuck in the Flash player side saying "Checking user/pass. Please wait".
    And neither onResult nor onStatus is called in FMS. Had it been calling onStatus for any relevant object as FMS defines, I could have proceeded further. But really not working and no clues at all.

        I have been trying to see if I can get some clue using service capture, but in vein. it is not showing anything. I am really stuck.

    We are basically building a whiteboard which needs saving of the activities of the user into the database for which calls from the FMS to AMFPHP are absolutely necessary. (To use loadvars/XML  is just too much boring / time consuming / unmanageable solution in the long run  ). I really do not want to go to use Loadvars/XML.

    Your tutorials are really excellent and it seems that you have 100 % succes  with FMS-AMFPHP  and I am wrong somewhere, though basic setup is quite well and working with Flash-AMFPHP, just getting in trouble with FMS-AMFPHP. Can you kindly attend this. Any help is really appreciated.

    I was about to post screenshots, but as nothing seems to be there in live log, I thought it would foolish of me to post a picture with no message in it.

    Swapnil

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #1 on: 03/14/07, 09:20 »
    Jorge,
        Also if you need any clarification/ more explanation of the scenario I am working in, i can describe in detail with pictures if any.

    Thanks adn best regards,
    Swapnil

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #2 on: 03/15/07, 02:08 »
    Any reply is really appreciable. Thanks in advance

    Swapnil

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #3 on: 03/15/07, 02:29 »
    To give any advice, we do need some more detail.

    What are the messages, if any?
    How does the methode you call look like?
    How do you call it?
    Are you 100% sure the serverside procedures are running ok?
    happy flashing
    8)
    Ronald

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #4 on: 03/15/07, 05:23 »
    Hello Ronald,

    Thank you for your response.

    You mean to say, should we check FMS or remoting stuff ?

    We have saved your FLA in flash 8 format and exported for AS 2. These are the only changes. We commented FMS related code and tested for plain remoting. It works perfectly without hitch.

    BTW, all FMS samples given by MM(currently Adobe) are working fine.

    I am pasting the changed code here

    Code: [Select]

    stop();
    /*
    function login(){
    //Check if the username have at least 4 chars
    if (username.text.length<4){
    message.text = "Please enter username (minimun 4 characters)";
    return;
    }
    //Check if the username have at least 4 chars
    if (password.text.length<4){
    message.text = "Please enter password, minimun 4 characters";
    return;
    }
    //Show a waiting message
    message.text = "Checking user/pass. Please wait";
    //Disable the push button
    loginButton.setEnabled = false
    // Create a connection Object
    client_nc = new NetConnection();

    // Handle status message
    client_nc.onStatus = function(infoObject){

    trace("on status of client");

    if (infoObject.code == "NetConnection.Connect.Rejected")
    {
    message.text = "Wrong username or password. Try again";
    loginButton.setEnabled = true
    }
    if (infoObject.code == "NetConnection.Connect.Failed")
    {
    message.text = "Connection to server failed. Try again";
    loginButton.setEnabled = true
    }
    if (infoObject.code == "NetConnection.Connect.Success")
    {
    gotoAndStop(2)
    }
    }

    // Connect to the application
    client_nc.connect("rtmp:/login", username.text, password.text);
    }

    loginButton.setClickHandler("login");

    /*/
    ////////////////////////////////////////////////////////////////////////////////////
    //// If you want to check first your method using only Remoting (Whitout FlashCom)
    ////  comment all above lines and uncomment below lines. Set the "path to your gateway.php"
    /////////////////////////////////////////////////////////////////////////////////////

    import mx.remoting.*;
    //import mx.remoting.debug.NetDebug
    stop();
    function login(){
    NetServices.setDefaultGatewayUrl("http://localhost/testFMS/login/gateway.php");
    var gatewayConnection = NetServices.createGatewayConnection();
    var service = gatewayConnection.getService("login", this);
    //call the server function
    var callServer = service.authenticate(username.text, password.text);
    //handle server response
    this.authenticate_Result = function(result){
    if(result)
    {
    gotoAndStop(2)
    }
    else
    {
    trace("check username or password");
    }
    }
    //Manage possible errors
    this.authenticate_Status = function(status){
    trace("Error")
    }
    }
    loginButton.setClickHandler("login");



    The above code works fine. We have made no change to your PHP files except changing gateway file's include path and database credentials in inc_sql.php.

    Gateway.php is as follow

    Code: [Select]
    <?php
    //default gateway
        
    include "amfphp/Gateway.php";
        
    $gateway = new Gateway();
        
    $gateway->setBaseClassPath("./services/");
        
    $gateway->service();
    ?>


    inc_sql.php is as follows
    Code: [Select]
    <?php
    ########################
    # SQL parameters
    ########################
    // Here You must define a user, password and host to match your needs. 
    // Debug flag outputs full error messages when installing
    define ("USERNAME","root");
    define ("PASSWORD","swapnil");
    define ("HOSTNAME","localhost");
    define ("DATABASE","Login");
    define ("DEBUG""true");
    ?>


    The above code is absolutely working fine.

    Here is the code for main.asc file

    Code: [Select]
    // ActionScript Communications Document
    //NetServices class library
    load("netservices.asc");
    application.onConnect = function(clientObj, username, password)
    {
    trace("this is in on connect");
    //application.rejectConnection(clientObj);
    //Modify the path to match your needs !!!!!

    NetServices.setDefaultGatewayUrl("http://localhost/testFMS/login/gateway.php");
    var gatewayConnection = NetServices.createGatewayConnection();

    for(var i in gatewayConnection)
    {
    trace(i + " = " + gatewayConnection[i]);
    }

    var service = gatewayConnection.getService("login", this);
    //call the server function
    var callServer = service.authenticate(username, password);
    //handle server response
    this.authenticate_Result = function(result){
    manageConnection(clientObj, result);
    }
    //Manage possible errors
    this.authenticate_Status = function(status){
    manageConnection(clientObj, false);
    }

    }
    manageConnection = function(clientObj, isAuthenticated){
    if(isAuthenticated){
    application.acceptConnection(clientObj);
    } else application.rejectConnection(clientObj);
    }

    We have just put some trace statements which definitely will not do any harm for sure.

    I hope this helps to clarify my settings and my code.

    Thanks and best regards
    Swapnil

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Problem with FMS and AMFPHP
    « Reply #5 on: 03/15/07, 13:16 »
    Ok, I get some time to re-run the example.
    Note that this tutorial was writed on 2003, so many time since there ...
    With the last amfphp distribution I did this changes:

    - Move login.php and inc_sql.php to amfphp\services
    - Modify main.asc to connect to the amfphp gateway on default location (amfphp version 1.2, download from amfphp.org)

    NetServices.setDefaultGatewayUrl("http://localhost/amfphp/gateway.php");

    That's it. Since locations changed since version 0.5 (the one I used at time of writing the tutorial), things should move accordingly.

    Jorge

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #6 on: 03/17/07, 05:06 »
    Thank you Jorge and Ronald,

    We got it solved, it was just a problem of assignment of security rights to the anonymous user under which any call to http://localhost runs. But i still wonder how a direct call from flash to remoting can pass through without giving anonymous access. Its surprising really !!!.

    Is it that, when we run swf by compiling in the flash IDE, it runs under administrative account ?

    However, thanks for attending my queries and generous help (which helped me keep my cool).


    Thanks and best regards
    Swapnil



    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Problem with FMS and AMFPHP
    « Reply #7 on: 03/17/07, 07:31 »
    The call is done by FMS, not the swf

    Jorge

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #8 on: 03/17/07, 08:54 »
    as long as you are running your application within development environment, some of the sandbox violations do not show.

    But as soon as you are running it in the player environment, sandbox security is enforced.
    happy flashing
    8)
    Ronald

    swapnilmali

    • Server what's that
    • *
    • Posts: 6
      • View Profile
      • Email
    Re: Problem with FMS and AMFPHP
    « Reply #9 on: 03/20/07, 03:47 »
    Hello Jorge and Ronald

    Thank you for your informative suggestions. Both of you are absolutely right.

    It helped me.


    Thanks and best regards,

    Swapnil Mali