Part of the EllisLab Network
This thread is a discussion for the wiki article: AMF Flash Remoting with Zend and CI
   
1 of 3
1
AMF Flash Remoting with Zend and CI
Posted: 05 January 2009 12:29 PM   [ Ignore ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

Hello everyone,

Just wanted to let you know that I created a new Wiki article on integrating the minimal Zend Framework with CodeIgniter specifically for using the new AMF Remoting classes.  Please let me know if you see any glaring errors on my part so I can make corrections to the article and on my projects.

Thanks,

http://codeigniter.com/wiki/AMF_Flash_Remoting_with_Zend_and_CI/

Profile
 
 
Posted: 07 January 2009 12:26 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  24
Joined  12-01-2008

very nice code! thanks

Profile
 
 
Posted: 23 January 2009 10:31 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  1
Joined  01-23-2009

Great code! I can now use other zend libraries if I wanted to…just did a test with currency.

 Signature 

http://www.reverbnation.com/willamar

Profile
 
 
Posted: 26 January 2009 04:07 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  15
Joined  07-25-2008

Thanks Matt, great work!

Part 1.C. I think you meant (system->application->config->hooks) instead of (system->application->hooks). Part 1.D. goes in (system->application->hooks).

Awesome!

Dave

Profile
 
 
Posted: 11 February 2009 03:12 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  8
Joined  01-27-2009

Is this example working for anyone?  I can’t get it working.  Everything is so simple in this example…it’s making me wonder if it works on the flash side for anyone.  I can only output amf to flash if I have a page outside of my /system/ folder.  If create a page outside of ‘system’, then I can link to a class inside, but when I try to use CI helpers, flash chokes again.

I am so sick of this message!!! “NetConnection.Call.BadVersion” that’s all I get.  If I place the main file outside of system, I can see the returned results.

Profile
 
 
Posted: 11 February 2009 05:42 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  8
Joined  01-27-2009

I have been looking at the output using Charles.  When this is working properly - outside of codeigniter - the MIME type is listed as
“Content-type: application/x-amf”

anytime I have any part of this application inside CI, the mime type is listed as
“Content-type: text/html”

I think this is a problem of codeigniter sending headers that are confusing flash?  ideas? help!

Profile
 
 
Posted: 12 February 2009 11:35 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

seansmith57,

I just replied to your email.  Take a look and I’ll do what I can to help you out.

Profile
 
 
Posted: 12 February 2009 11:56 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

Since I’m in the middle of a project that’s using this code, I actually just got the error that you were talking about “NetConnection.Call.BadVersion”.

It was caused in my case because I entered the wrong database password in my config file, so the Remote controller threw a PHP error.  That error then caused the Zend AMF Server to fail, which in turn cascaded down to Flash. 

So in your case, if I had to guess, you have something being called before the Zend AMF Server that’s failing, possibly one of the CI helpers that you mentioned.  You might want to comment out the Zend code and test the other functions that you’re calling to make sure they’re working properly.  If its still not working after that, we can try and figure out the source of the errors.

Profile
 
 
Posted: 12 February 2009 05:04 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  8
Joined  01-27-2009

I resolved this, but it doesn’t make a lot of sense to me. 

I got the same errors on a different server using an identical hook system of grabbing zend classes (to the one in this example.)  Then I tried getting rid of the hooks (I never liked doing that anyways) and made a hack in my libraries folder for auto loading zend classes.  I got rid of everything related to hooks from the example here and all of a sudden it worked.  I went back to the production server and got the same results. 

I would be very interested in figuring out what really caused errors for me when using hooks, but it’s working, so I’m moving on.

Profile
 
 
Posted: 19 February 2009 12:37 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  3
Joined  02-19-2009

I’m having similar challenges with the posted example for CI & Zend-AMF integration. I followed the instructions on the wiki page exactly and am also getting the ‘NetConnection.Call.BadVersion’ error code back. I ran the method without the server by printing the return of the ‘getData’ method - data is printed as expected and no php errors are produced. With the server enabled I get the appropriate ‘Zend Amf Endpoint’ echoed out, again with no php errors produced. I also tried connecting to the server with Flex but got the same error code back.

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

Flex Error:
[FaultEvent fault=[RPC Fault faultString=“Send failed” faultCode=“Client.Error.MessageSend” faultDetail=“Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: ‘http://localhost/remote.php’”] messageId=“6CBC5580-4066-2712-49D1-8CFD1E9DC4B0” type=“fault” bubbles=false cancelable=true eventPhase=2]

I am new to CI and remoting in general though I have been using Flash and related technologies since version 3. I would very much like to get the Zend AMF server up and running either through some help with troubleshooting the error returned with the existing setup or by getting some help initializing the Zend AMF server through the ‘library hack’ mentioned by seansmith57 - as I said, I’m new to CI.

I’m using the latest version of MAMP, CI and ZEND Framework with Flash CS3/Flex 3.

Any help would be greatly appreciated! I’m getting tired of using SOAP with all the inherent xml overhead! wink

Thanks in advance for any help rendered!

Profile
 
 
Posted: 19 February 2009 02:24 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

I’ve been looking into this since the last post with problems and its a difficult one to track down, because with AMF a lot of things can go wrong.

If you read the Flash documentation, you’ll see that “NetConnection.Call.BadVersion” is thrown when your Flash movie is expecting AMF data and gets plain text instead.  So that means that you have one of the following problems:

1. You have errors in your PHP code that are being output during the call
2. You are calling the remoting method incorrectly from flash, producing “not found” errors
3. You do not have hooks enabled correctly to load Zend classes
4. Any number of other environment issues ???

I’ve also been reading about people having AMF problems when working on a local test environment like MAMP, WAMP, or XAMMP.  This example was created and tested using a live Linux development server and is currently in use on several live sites with no problems. 

I’m going to try and figure out a better means of debugging, but for now the best thing you can do is just really check your code for errors and try to find the part that’s causing PHP to return text errors instead of AMF data.

Profile
 
 
Posted: 19 February 2009 02:45 AM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

For those working locally on WAMP, MAMP, etc.  Try changing your .htaccess file and see if that helps.  Local environments can be a little screwy sometimes.  I’m looking into a few other potential fixes and will post anything I find.

RewriteEngine on

RewriteCond
%{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^(.*)$ index.php/$1 [L]
Profile
 
 
Posted: 19 February 2009 10:36 AM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  3
Joined  02-19-2009

Thanks for the response drezden97!

Good to know that MAMP may be the source of the problem. By default the MAMP setup does not output PHP errors to the client, but rather to log files which I checked to no avail.

I have used Zend-AMF recently without CI and had success locally - of course at the time I used the stock Leopard Apache/PHP setup for that, I will have to try that code with MAMP and see if it still works. <OT>I’m trying out MAMP as it has the GD extension not included by default with the stock Leopard PHP - been quite a nightmare trying to get a local solution working with GD.</OT>

I will also try changing the .htaccess file tonight as you suggested.

BTW, I very much appreciate the how-to you setup for integrating CI and Zend-AMF! I learn best through such clear and concise examples! The prospect of having to learn the Zend framework now that I have spent a fair amount of time going through the CI documentation was a little depressing!

Profile
 
 
Posted: 19 February 2009 09:32 PM   [ Ignore ]   [ # 13 ]  
Summer Student
Total Posts:  3
Joined  02-19-2009

Okay. So I tried the different .htaccess file ... but no luck - still getting the error.

I did try the ‘library hack’ of seansmith57’s which is working great ... unfortunately I do not understand enough about CI yet to figure out why so I’m just going to run with it for now.

Thanks so much for the help!

Profile
 
 
Posted: 26 February 2009 03:13 PM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  12
Joined  07-24-2008

DaveO and I were working on a project this week that was using the Zend AMF Server and we encountered a “BadVersion” error that was eventually tracked down to an AMF Encoding issue. 

We were able to find a workaround that solves the problem and I have posted it to the Wiki as Part 4.  So for anyone trying to implement the Zend AMF Server, I’d encourage you to read the last section and give it a shot if you encounter any problems.

Thanks!

Profile
 
 
Posted: 03 March 2009 05:48 PM   [ Ignore ]   [ # 15 ]  
Summer Student
Avatar
Total Posts:  4
Joined  03-03-2009

Spaces! Dam spaces! wink
I’ve been trying to get this to work and I was getting that stupid error
“Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion”

Anyway it was a space that was causing it, in my Apps.php file after the closing PHP tag.

Deleted any rouge characters from the top and bottom of the files, it all works and now I can go to bed.

It kinda makes sence I suppose that rouge space was making the server return the request as “text/html” rather than “application/x-amf”

Profile
 
 
   
1 of 3
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120316 Total Logged-in Users: 52
Total Topics: 126437 Total Anonymous Users: 3
Total Replies: 664887 Total Guests: 500
Total Posts: 791324    
Members ( View Memberlist )