Hello,

I'm not sure if I'm doing something wrong or if there is a bug in my drupal site (www.ewantavener.co.uk).

I have the following installed:
Drupal 6.16
Services 6.x-2.0
AMFPHP 6.x-1.0-beta2 (placed at the root of the modules dir, I've seen something saying to put in the module/services/server folder?)

When I run a service on the services page on my site it works with no issues. However, I'm having problems connecting to the services from my flash file (running from my local docs folder). I get a NetStatusEvent error saying 'NetConnection.Call.BadVersion' I've looked into this and it says it's likely to be a php error/problem.

I was trying to run the 'view.get' method and this was not working so I have also tried with 'system.connect' as it does not require any arguments or api keys, but I still get the same error. I have also changed some permissions so that I can access the methods as an unauthenticated user (there does not seem to be a specific permission for the view services).

Any ideas what this problem could be? Have I installed something incorrectly> Is there a bug? Or is it a problem with my Flash?

I've been stuck on this for a while now and would be very helpful if you could help me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

etavener’s picture

FileSize
608.09 KB

Screenshot of the log screen. The times don't coincide with errors in flash but do with module installations

marcingy’s picture

Project: Services » AMFPHP
Version: 6.x-2.0 » master
Component: Code » Miscellaneous

Moving the queue as this might get more help here.

etavener’s picture

Ok, I have it working using flex. However, I would prefer to use flash.

In flash it is still coming up with 'netconnection.call.badversion'. I have service capture picking up an error saying

Fatal error: Uncaught exception 'VerboseException' with message 'Standalone Flash player disabled. Update gateway.php to allow these connections' in /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/sites/all/modules/services/servers/amfphp/amfphp/core/amf/app/Gateway.php:357
Stack trace:
#0 /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/sites/all/modules/services/servers/amfphp/amfphp/core/amf/app/Gateway.php(357): amfErrorHandler(256, 'Standalone Flas...', '/websites/123re...', 357, Array)
#1 /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/sites/all/modules/services/servers/amfphp/amfphp.inc(22): Gateway->disableStandalonePlayer('Standalone Flas...', 256)
#2 /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/sites/all/modules/services/servers/amfphp/amfphp.module(58): amfphp_server_exec()
#3 /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/includes/module.inc(462 in /websites/123reg/LinuxPackage21/ew/an/ta/ewantavener.co.uk/public_html/portfolio/sites/all/modules/services/servers/amfphp/amfphp/core/amf/app/Gateway.php on line 357

Any ideas on how to fix this?

Sylvain Lecoy’s picture

Do you compile with the Flash CS4 IDE Compiler or the Flex compiler in Eclipse (Flash Builder) ?

In the first case you'll get BadVersion error, in the second case it should fixe the problem. Came across this issue and concluded it was the compiler.

If you find how to fixe it in Flash IDE let me know, otherwise, try my work around and tell me if that solved the problem.

Sylvain Lecoy

Drupal_rocky’s picture

Is AMFPHP still the only and easiest game in town? In the current release of Flash Builder 4 they have integrated with ZendAMF?
Can you point me to the best place to visit for a working tutorial for using drupal with AMFphp if that is the current option?

It does seem like things are moving towards zendAMF. Any modules that make it easier to use zendAMF?

etavener’s picture

OK, I'm getting really fed up with this now. I had it working calling the 'views.get' method. I have left it for about of week. And now I get an access denied message (I have not changed a thing). I get this message when I run the method in the browser and logged in. Any ideas why this is?

drupal@guusvandewal.nl’s picture

I'm having the same problem:

We are connected!!!
Session Id: 0l2d2of2a29mrkfdbftudv1464
ERROR ITEM: Geen toegang (Access Denied)
ERROR ITEM: AMFPHP_RUNTIME_ERROR
ERROR ITEM: /****/sites/all/modules/amfphp/amfphp.inc
ERROR ITEM: Unknown error type
ERROR ITEM: 74
snelson’s picture

Version: master » 6.x-1.0-beta2

Can you try the previous beta of AMFPHP to see if that works for you? If it does then we can narrow down the issue to the new beta.

gdoteof’s picture

Priority: Normal » Critical

Just chiming in here.

I have had a long time working flash app that connected using the beta1 of this module, upgrading to beta2 breaks the connection without any change to the flash app itself

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion

This happens on system.connect

esteewhy’s picture

Confirm

While 6.x-1.0-beta2 gives an error as above, 6.x-1.0-beta1 works fine, at least on system.connect.

Jetson’s picture

Hi-

I'm having the same issues.

I rolled back to beta1 - instead of a error #74 I now get #106 !??

Thanks!

hamsterbacke42’s picture

In my case the Boost module made trouble... quite obvious if you think about it

kevinsbath’s picture

Exact same problem here!

AMFPHP module -
With Beta 1 - error #106
With Beta 2 - error #74

Most frustrating...

drupal@guusvandewal.nl’s picture

EDIT:

Services is working great in combination with views2. I have the following modules installed:

AMFPHP 6.x-1.0-beta2
Services 6.x-2.1
Views 6.x-2.10 //I guess later version also work fine
Make sure access rights are set in /*/admin/user/permissions

AS3 Code in *.as

// Declare our variables
//Security.allowDomain("*");
//Security.loadPolicyFile("http://localhost/YOURDIRECTORY/DRUPALINSTALLNAME");
var baseURL:String = "http://localhost/YOURDIRECTORY/DRUPALINSTALLNAME";
var gateway:String = baseURL + "/services/amfphp";
var sessionId:String = "";
var viewName:String = "THE_NAME_OF_YOUR_VIEW"; 

// Declare our Drupal connection
var drupal:NetConnection = new NetConnection();
drupal.objectEncoding = ObjectEncoding.AMF3;
// Connect to the Drupal gateway
drupal.connect( gateway );
// Set up our responder with the callbacks.
var responder:Responder = new Responder( onConnect, onError);
// Connect to Drupal
drupal.call("system.connect", responder);
// Called when Drupal returns with a successful connection.
function onConnect( result:Object )
{
   // Set our sessionId variable.
   sessionId = result.sessid;
   trace("We are connected!!!");
   trace("Session Id: " + sessionId);
   // Load our "Hello World" node (ID = 1)
 //  loadNode( 1 );
   
   
    // If they provided a view name. 
   if( viewName ) { 
      // Load the view. 
      loadView( viewName ); 
   } 

   
}

/*
function loadNode( nid:Number )
{
   // Set up our responder with the callbacks.
   var nodeResponse:Responder = new Responder( onNodeLoad, onError);
   // Call Drupal to get the node.
   drupal.call( "node.get", nodeResponse, sessionId, nid );
}
*/

// Loads a Drupal view. 
function loadView( _viewName:String ) 
{ 
   // Set up the responder with the callbacks. var viewResponse:Responder = new Responder( onViewLoad,onError ); 
   // Call Drupal to load the view.
   var viewResponse:Responder = new Responder( onViewLoad, onError);
   drupal.call( "views.get", viewResponse, sessionId, _viewName ); 
} 


// Called when Drupal returns with our node.
function onNodeLoad( node:Object )
{

 
 
}

// Called when a view gets loaded. 
function onViewLoad( _view:Object ) 
{ 
   trace( "View loaded" ); 
   var first_ARRAY:Array = new Array;
   // Iterate through all of the nodes. 
   for each( var node:Object in _view ) 
 
   { 
   
      trace( node.nid );  
	   trace(node.node_title);
	  // trace(node.node_data_field_huisnummer_field_huisnummer_value); //from views.get
	  
	 first_ARRAY.push(node);
	   
	
		  
   } 
   
   for ( var i:String in _view ) 
   
   {
	   first_ARRAY.push(i);
	   
	   //trace(i);
	  trace('array: '+first_ARRAY[i]);
	     
		  

   }


} 






// Called when an error occurs connecting to Drupal.
function onError( error:Object )
{
    for each (var item in error) 
    {
       trace("error: "+item);
    }
}
 

Hope this helps!

Guus

pagemaker’s picture

Title: Problem with Services, AMFPHP and Flash » Problem with Services, AMFPHP and Flash 'NetConnection.Call.BadVersion'
Component: Miscellaneous » Code

Thank you Guus,
I use nearly the same AS3 code, making just the call to Drupal and getting the blasted #2044 NetConnection.Call.Badversion error.
I Use:
Administer > Site building > Modules
Services
Services 6.x-2.2
Services – authentication
Key Authentication 6.x-2.2
Services – servers
AMFPHP 6.x-1.0-beta2
Services – services
Node Service 6.x-2.2
System Service 6.x-2.2

Administer > Site building > Services
Services > Browse
Servers
AMFPHP - /services/amfphp
Clicking on this link shows gladly: “amfphp and this gateway are correctly installed”.

Services > Keys
Key hexadeciebeesie
Title Hello Drupal
Domain localhost:8080/flashdrupal
Services > Settings
General
Authetication module: Key authentication
Use keys Checked
Use sessid Checked

AMFPHP
Leave deafaults as is

Administer > User management > Permissions
Node_service module
Load node data anonymous user ^ authenticated user checked
Services module
Administer services anonymous user ^ authenticated user checked

Used URL in AS:
var baseURL:String = "http://localhost/flashdrupal";
var gateway:String = baseURL + "/services/amfphp";

Connection is OK, but Call fails; what the h... am I doing wrong?

Please Help.

drupal@guusvandewal.nl’s picture

FileSize
93.61 KB

Not sure,

perhaps you should downgrade the services module to the exact version I described earlier. That helped me out.
then use my code and see if it works... and adapt.

I only use session ID's, see attachment.

Good luck

pagemaker’s picture

Copied exact your installation AMFPHP 6.x-1.0-beta2 and Services 6.x-2.1; no use keys.

Apache access_log says: ::1 - - [26/Jun/2010:13:11:08 +0200] "POST /flashdrupal/services/amfphp/debuggateway.php HTTP/1.1" 200 1174 "file:///C|/Flash%20AS%203.0/Flash%20Drupal/flashdrupal.swf" "Shockwave Flash"

Tried with this prog:

echo "Test cURL:  http://localhost/flashdrupal/?q=services/amfphp/debuggateway.php";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/flashdrupal/?q=services/amfphp/debuggateway.php');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch); 

print '<pre>';
print 'cURL respons: ' . $data;
print '</pre>';

Output:
Test cURL: http://localhost/flashdrupal/?q=services/amfphp/debuggateway.php

cURL respons: HTTP/1.1 200 OK
Date: Sat, 26 Jun 2010 11:20:03 GMT
Server: Apache/2.2.12 (Win32) DAV/2 mod_autoindex_color PHP/5.3.0
X-Powered-By: PHP/5.3.0
Set-Cookie: SESSef371646d4318a6227e524bbb041a8e1=vu6l9fjsmlm0mgff7n02v9ttv5; expires=Mon, 19-Jul-2010 14:53:23 GMT; path=/
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sat, 26 Jun 2010 11:20:03 GMT
Cache-Control: store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Content-Length: 437
Content-Type: text/html; charset=utf-8

amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.

Note: If you're reading an old tutorial, it will tell you that you should see a download window instead of this message. This confused people so this is the new behaviour starting from amfphp 1.2.

View the amfphp documentation

Load the service browser

So this seems to be OK.

But still the blasted "#2044 NetConection.Call.Badversion" error report. I've run out off ideas, please help!

I did all of the above and in php/php.ini
define(PRODUCTION_SERVER, false)
setLooseMode(true);
log_errors = On

remove .htaccess

error_log .../php_error.log remains empty

Did I forgot something? Please help me out!

pagemaker’s picture

That took me quite some time!! Bud finally I conquered the blasted “#2044 Bad Version” error.
Here’s what I did – and I did it twice just to be sure:
1.
Download a fresh XAMPP (lite or full) and install this in C:/ - installing in C:/Program Files runs a risk of writing problems. Under W7 make sure port 80 is free!!
2.
Download and install a fresh Drupal site – I took version 6.17.
3.
Download and activate modules: Services 6.x-2.2, Amfphp 6.x 1.0-beta2.
4.
Download amfphp 1.9.zip (444,8 KB) from http://sourceforge.net/projects/amfphp/files/#files install the unzipt version in:
your-local-root/your-site-name/sites/all/modules/services/servers/amfphp just according to the book “Flash with Drupal”.
5.
See pictures for Services module settings, Services settings and Permission settings.
6.
Now you think it’s all set and should work, how wrong can you be. This is where Charles came to the rescue. Whith this http-sniffer I detected that you also have to change in:
…/sites/all/modules/services/servers/amfphp/amfphp/core/amf/app/Gateway.php
This:
//function disableStandalonePlayer($value = true) {
In:
function disableStandalonePlayer($value = false) {
It was my experience that you have to change it here and nowhere else!!
7.
And now finally I saw my connection work!
I’m quite sure this is going to help someone somewhere, good luck!

Amarjit’s picture

Excellent pagemaker.

I have the same setup as you and the above fix works.
You may also want to install this patch. It fixes the 'system.connect' button within the services admin page.

Daniel Norton’s picture

Category: support » bug
Status: Active » Needs review
Issue tags: +services, +flash, +Adobe, +Flex
FileSize
1.45 KB

This patch should fix the original poster's problem.

The previous configuration had hard code to prohibit standalone Flash players from accessing AMFPHP services. This patch to 6.x-1.0-beta2 adds an admin setting to allow or prohibit such access.

After installing this patch, change the setting here:
.../admin/build/services/settings/amfphp

The code that was ported and used by this module copied a hard-coded initialization setting that prohibited standalone Flash players from accessing services. By original design, that setting would have been modifiable by the installer by changing those same startup settings. This module, however, provided no such option to modify this setting, making this module unusable for such configurations. The priority of "critical" is appropriate and because the port placed an unnecessary and severe restriction on the configuration, I changed this status from a "support request" to a "bug report".

justinlevi’s picture

FYI - This last patch threw errors for me.

patching file amfphp/amfphp.admin.inc
patching file amfphp/amfphp.inc
Hunk #1 FAILED at 19.
1 out of 2 hunks FAILED -- saving rejects to file amfphp/amfphp.inc.rej

Bensbury’s picture

Hi,

I have AMFPHP and Drupal working fine and have done for a long time on both MAMP, WAMP and various production servers and different flavours of Drupal. I have also had it working with the GAIA Framework too.

I'm just saying this to give AMFPHP confidence that it does work, and it's very cool.
I compile with the Flash IDE in CS4 if that helps anyone.

If you are trying to get it to work for the first time and reckon I could help you out, drop me an email and I'll see if I can.
A long time ago I posted up zip files with a working example and code for it, but it seems to have disappeared down the Drupal chute.

All I know is recently I downloaded all Fresh drupal, services and amfphp for a new site, installed as usual and off it worked.
The only hassle I have is the character encoding bug which is worth remembering everytime:

http://drupal.org/node/374738

bartwybouw’s picture

Hi Pagemaker,

I'm also following the book and am stuck ...

I've tried the patch, and I did your manual "hack" ;-) ... result is still this

We are connected!!!
Session Id: 43f4498164a2af2acb03f3764595e283
AMFPHP_RUNTIME_ERROR
Unknown error type
/Applications/MAMP/htdocs/drupal-6.17/modules/services/servers/amfphp/amfphp.inc
74
Missing required arguments.

I'm running this on Mac OSX 10.6.4, using MAMPRO 1.9

Daniel Norton’s picture

@bartwybouw, the patch I provided was for 6.x-1.0-beta2, which isn't installed in the "services" module directory, but in its own directory. (And where is sites/all ?)

imp7’s picture

I was just getting this same error with a stupid php mistake, so when you are checking make sure your php has no errors.

bartwybouw’s picture

I ended up fixing it by using the exact combination of modules and versions as was described in the book. It does point out though that this Flash-Drupal-AMFPHP is a far from stable environment

I would not want to run production using these. One update and the whole site falls apart.

imp7’s picture

There are many instances of Flash-Drupal-AMFPHP being used in many successfull sites. Updates in anything has always required everyone to participate in testing, its just the nature of the beast. Good to hear you got it working, this is truely a powerfull combination and looks like the services module is just getting better :)

zed_den’s picture

I´m running into the "NetConnection.Call.BadVersion" Problem.
Comment # 18 works for me.
Thank you very much pagemaker!

monti’s picture

have just joined the discussion -

related modules versions:
Services 6.x-2.2
Key Authentication 6.x-2.2
AMFPHP 6.x-1.0-beta2
Node Service 6.x-2.2
System Service 6.x-2.2

simple test code, similar to #14 above, after modifying Gateway.php as in #18

Output:
connected!!!
Session Id: b05167273e59d393f592fecc9da4228e
Missing required arguments.
74
AMFPHP_RUNTIME_ERROR
/home/projects/last/sites/all/modules/amfphp/amfphp.inc
Unknown error type

any idea ?

cheers !

monti’s picture

Just a little more related information -

when using the method through "admin/build/services/browse/node.get"
I was able to receive the "Missing required arguments" error only if nid was empty.
otherwise, it responded with the expected data.

drupal@guusvandewal.nl’s picture

Hi,

@monti
regarding your errors:
-Missing required arguments.
-74

Make sure the Key Authentication Module is enabled
Do not select 'use keys' set Token expiry time to 30 seconds(default) and select use sessions id's on /**/admin/build/services/settings ...

If this still fails make sure your access rights are also set...
/**/admin/user/permissions

Hope this helps

Gus

monti’s picture

@guusvandewal - thanks for giving it a try.

My issue was eventually solved by using an OLDER version of services module as suggested here - http://drupal.org/node/478200#comment-3658766

I am posting back for anyone else, who might follow this discussion and encounter similar error.

monti’s picture

Node read, update, create works properly with the older version but along with an error:
preg_match() expects parameter 2 to be string, array given in /home/projects/last/includes/bootstrap.inc on line 771.

Any idea anybody?

Same message, by the way, appears to be fixed with uc_paypal - http://www.ubercart.org/forum/support/12633/attribute_arrays_cause_boots...

Edited:
Have modified the ActionScript code entirely. Error doesn't show anymore. Unfortunately, cannot pinpoint the exact cause. As said - the change was throughout the code.
I leave the message here, in case others would like to elaborate or get a hint as to where to look for the cause. I didn't think of looking there, and unintentionally fixed it while rewriting the error containing code.

wendell’s picture

I have seen a lot of comments of people struggling. Sometimes because of modules being in flux, but sometimes because things aren't well documented?

I am starting to put together some documentation. If you want to drive right in and get a quick start with Drupal, AMFPHP/Services and Flash, please check out this draft:

http://www.wwbtc.com/content/easy-drupal-amfphp-flash

(and also download Example2.rar)

It may be useful to anyone still struggling. Included is an AS3 library to simplify calls to Drupal, and allows the use of Keys (for security!) A lot of the tutorials that I find suggest disabling keys.

Let me know what you guys think! I am working on a better write up :)

biteuljiouce’s picture

many thanks pagemaker

I had the following error :
Session Id: 9c2a7a54c39e487f619c975ebc51eXXX
AMFPHP_RUNTIME_ERROR
Unknown error type
/Users/cedric/Documents/work/xxxx/www/sites/all/modules/amfphp/amfphp.inc
74
Access Denied

I had a look to your screen captures (Comment # 18) and it worked for me :) :)

My mistake was : i forgot to check
Permissions settings > node_service module > load node data

I'm using :
Drupal 6.20
modules :
- Services 6.x-2.4
- Key Authentication 6.x-2.4
- AMFPHP 6.x-1.0-beta2
- Node Service 6.x-2.4
AMFPHP 1.9

next step will be using key, but for the moment, I only need to read drupal data ... so no security issue.

amaria’s picture

To solve this problem using the latest versions as of Jan 23, 2011, add the services_debug variable and set it to true. This way, no need for hacks/patches. Be sure to remove the variable on production servers.

vinothbabuog’s picture

Hi ,

We have working on creating an Online T Shirt Designing site using Drupal and Flex. The front site and the admininstration section are developed in Drupal and the design tool is developed in Flex. We are using the AMFPHP to connect the Drupal and Flex for interchanging the Data and Action script 3 for the establishing the connection between Flex and PHP and calling the remoting methods

In Action Script 3 we have the following :
import com.app.AppConf;
import com.left.MemorialInfoScreen;
import com.util.WaitScreen;
import flash.display.DisplayObjectContainer;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import mx.collections.ArrayList;
import mx.core.FlexGlobals;
public class RemoteConnection extends NetConnection
{
private var conf:AppConf = AppConf.getInstance();
public function RemoteConnection(sURL:String)
{
objectEncoding = ObjectEncoding.AMF0;
if (sURL)
{
connect( sURL );
}
}
}

And in the Main mxml file i have declared like this

protected function init(event:FlexEvent):void
{
conf = AppConf.getInstance();
gateway = new RemoteConnection("http://mydrupalsite.com/sites/all/modules/amfphp/amfphp/gateway.php");
conf.gateway = gateway;
conf.leftPanel = leftPanel;
conf.rightPanel = rightPanel;
}

I have created the remoting class file and placed in the amfphp/amfphp/services folder. The data are interchanging with Flex and Drupal when we using the gateway path http://mydrupalsite.com/sites/all/modules/amfphp/amfphp/gateway.php every thing working fine expect to create the Drupal user session when the user login from the Flex application. So i have changed the gateway path to "http://mydrupalsite.com/services/amfphp" and created the service-config.xml file and changed the endpoint uri to http://mydrupalsite.com/services/amfphp. When i have debug and Run the application from flash Builder IDE its showing the following error.

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion

Could Any one Help me on this.
Note : I am not a Flex Developer.

knowpixels’s picture

Intermittent Error with AMFPHP and Flash 'NetConnection.Call.BadVersion' - Services Module.
This error can occur when you send asynchronous flash calls to your custom modules own Drupal service(s) where some flash request objects have parameters and subsequent ones don't.
To prevent the error you need to start a new connection object in AS3 for each request as otherwise your connection object can be overwritten (when its initially called with no parameters and then re instantiated with different parameters from another flash method but its still the same connection object.
The 'NetConnection.Call.BadVersion' error will show when fired asynchronous requests don't come back in the same order they're fired, you'll get the Bad version error because your connection object is being over written with different parameters before its initial request returns data, so response data is coming back after the objects parameters and arguments have been overwritten. This is because asynchronous calls can always come back in a different order to when they are fired.
This stumped me for a while so hopefully this comment will help someone else in the same situation save a few hours of their wonderful life :)

apaderno’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Issue summary: View changes
Status: Needs review » Closed (outdated)
Issue tags: -services, -flash, -Adobe, -Flex

I am closing this issue, since it has been opened for a version that does not use a supported Drupal release. Furthermore, this project does not have versions for a supported Drupal release.