Skip to Content »

 Amazon S3 “RequestTimeTooSkewed” error

  • January 21st, 2010
  • 4:03 pm

I was trying to connect to S3 today, and both Transmit and Forklift were giving me connection errors:

XML:
  1. <Error>
  2.     <Code>RequestTimeTooSkewed</Code>
  3.     <Message>The difference between the request time and the current time is too large.</Message>
  4.     <MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>
  5.     <RequestId>68532E845A05B015</RequestId>
  6.     <HostId>FfoBOO+7Kh+0Aa35f+Oa0P+Beeym+10LNyLVTGI3VgEHkVjotak8+L1QHaWOsIaf</HostId>
  7.     <RequestTime>Fri, 22 Jan 2010 00:10:57 GMT</RequestTime>
  8.     <ServerTime>2010-01-21T23:53:58Z</ServerTime>
  9. </Error>

The problem: my system clock was manually set 15 minutes fast. The s3 api will check the request time against the time on the server to see if it's been too long, and if it has, it returns the above error. Fixing the time solved it.

 Sending an ArrayCollection – Flex to amfphp

  • November 20th, 2009
  • 6:00 am

Here are my tweaks to amfphp for sending an ArrayCollection from Flex to amfphp. May not be the cleanest or most proper but it works. From what I understand, there is an ArrayCollection class included in Zend_AMF, but I haven't looked into that.

I've been sending ArrayCollections from php to Flex for a while, it's pretty simple and info for doing that can be found at Wade Arnold's blog here. The issue going the other direction is that Flex only sends the AC's underlying source array when serializing it for amf. So when amfphp unpacks the data, you're dealing with a normal array.

Obviously, the first thing you'll need is your ArrayCollection class to use (I use the version that extends ArrayObject at the link above), and make sure it is in your include path.

The first tweak to amfphp is to the method AMFBaseDeserializer->mapClass(). In that method, right after the checks looking for CommandMessage and RemotingMessage types, I added a similar check for ArrayCollection:

PHP:
  1. if($typeIdentifier == "flex.messaging.io.ArrayCollection")
  2. {
  3.         return new ArrayCollection();
  4. }

Next change is to the AMFDeserializer->readAmf3Object() method. Near the middle of the method, around line 570, there is a check for ArrayCollection, and if found it will call the readAmf3Data() method. I changed it to pass in a value of "true" to the method, you'll see why in a sec:

PHP:
  1. if( $classDefinition['externalizable'] )
  2. {
  3.     if($type == 'flex.messaging.io.ArrayCollection')
  4.     {
  5.         $obj = $this->readAmf3Data(true);
  6.     }

Now just two small tweaks to the readAmf3Data() method. I changed the method signature to add an $isArrayCollection parameter, which just gets forwarded on when calling readAmf3Array. Here's the whole method:

PHP:
  1. function readAmf3Data($isArrayCollection = false)
  2. {
  3.     $type = $this->readByte();
  4.    
  5.     switch($type)
  6.     {
  7.         case 0x00 : return null; //undefined
  8.         case 0x01 : return null; //null
  9.         case 0x02 : return false; //boolean false
  10.         case 0x03 : return true//boolean true
  11.         case 0x04 : return $this->readAmf3Int();
  12.         case 0x05 : return $this->readDouble();
  13.         case 0x06 : return $this->readAmf3String();
  14.         case 0x07 : return $this->readAmf3XmlString();
  15.         case 0x08 : return $this->readAmf3Date();
  16.         case 0x09 : return $this->readAmf3Array($isArrayCollection);
  17.         case 0x0A : return $this->readAmf3Object();
  18.         case 0x0B : return $this->readAmf3XmlString();
  19.         case 0x0C : return $this->readAmf3ByteArray();
  20.         default: trigger_error("undefined Amf3 type encountered: " . $type, E_USER_ERROR);
  21.     }
  22. }

Now just another two small tweaks to the readAmf3Array method. As with the readAmf3Data() method, we add the $isArrayCollection parameter. Within the body of the method, I just check if that param is true when creating the $hashtable variable, and if it is, use an ArrayCollection instead of a regular array:

PHP:
  1. function readAmf3Array($isArrayCollection = false)
  2. {
  3.     $handle = $this->readAmf3Int();
  4.     $inline = (($handle & 1)  != 0 ); $handle = $handle>> 1;
  5.  
  6.     if( $inline )
  7.     {
  8.         $hashtable = $isArrayCollection ? new ArrayCollection() : array();
  9.        
  10.         $this->storedObjects[] = & $hashtable;
  11.         $key = $this->readAmf3String();
  12.         while( $key != "" )
  13.         {
  14.             $value = $this->readAmf3Data();
  15.             $hashtable[$key] = $value;
  16.             $key = $this->readAmf3String();
  17.         }
  18.  
  19.         for($i = 0; $i <$handle; $i++)
  20.         {
  21.             //Grab the type for each element.
  22.             $value = $this->readAmf3Data();
  23.             $hashtable[$i] = $value;
  24.         }
  25.         return $hashtable;
  26.     }
  27.     else
  28.     {
  29.         return $this->storedObjects[$handle];
  30.     }
  31. }

That's it. Now I can send the an AC to the server, serialize it, unserialize it and send it back to Flex with no issues. The one thing that may an issue is if one of the items within an AC is also another AC...haven't checked out if that works yet.

 Frameworks 2.0

  • November 2nd, 2009
  • 12:19 am

Subititled: "The Rise of 'Burger King' frameworks....'have it your way'".

I am loving the new trend I'm seeing in a lot of the frameworks (both client- and server-side) I've been checking out lately. What I'm seeing is a move away from the monolithic, "do it my way or suffer trying to work around it" approach, towards more architectures that provide a more generalized, "less is more" approach, even to the point that some of the functionality and/or features of the "do-it-all" frameworks are being broken out into smaller, specialized bits that allow the developer to pick and choose between whichever approach best suits their style.

To me, the main benefit of the new trend is readily apparent: just as different individuals would write the same story different ways, the same goes for writing code. For one framework to dictate too much influence over too many aspects of an application, or even worse to make it difficult to extend or adapt to suit your needs, provides too much lock-in and and can hinder more than it's trying to help.

On the flash/flex side, frameworks like RobotLegs , Cairngorm 3, Gaia, and even libraries like CasaLib provide example of this (ok, Gaia probably goes a little further as far as initial structure, but once you start developing it stays out of your way). On the backend, for php you have things such as Konstrukt, a "URI-to-controller-mapping" (i.e., REST) framework which handles "routing based on logic rather than rules", and the Outlet and phpDataMapper ORM frameworks.

One thing about the above mentioned frameworks is that most, if not all, can be used in conjunction with each other (like so). If you don't like the way one part does it's job, you can more than likey swap out that part with a similar one without affecting the other parts of an application, provided you we good with encapsulation and keeping things pretty cleanly separated. This is not an insignificant side effect of the "less-is-more" approach, it's the central theme. It's having it your way.

 Thank you, Steve Webster

  • October 27th, 2009
  • 9:20 am

Since I always like to give credit where it's due, I just wanted to send a quick thanks to Steve Webster, who noted on his blog today today that he's moving on from Flash/Flex development. His book "Foundation PHP for Flash", as well as his help through the various flash forums and email, were absolutely pivotal in my flash dev career.

 Atlassian Offering $10 Starter licenses for most products

  • October 7th, 2009
  • 10:39 am

I use JIRA a lot, i think it's probably the best issue-tracking tool, even one of the best overall web-based applications out there. Today I received an email that Atlassian is offering starter licenses for six of its products at $10 each: JIRA, Confluence, Green Hopper, Bamboo, Fisheye, and Crowd. You get 10 users each for JIRA, Confluence, and Green Hopper, 10 plans on Bamboo, 10 committers on FishEye, and 50 users on Crowd. A great deal for some great products.

 Gaia – Yeah, I’m gonna have to give it props again

  • September 29th, 2009
  • 11:59 pm

I know I just posted about Gaia recently, but I'm just about to wrap up the same project and after working with it some more and getting to know it a little better, I really have to say again how impressed I am with it. I'll put it this way: it was the first framework of any kind that I actually enjoyed getting into. SO MUCH of the kaka grunt work is taken care of for you, it just makes development a breeze, and flexible enough to allow you to do whatever you need to do. Much more of an "I'm here to help" vibe then the "YOU WILL FOLLOW MY RULES OR I WILL MAKE YOUR LIFE MISERABLE" crap found in just about every other framework.

I'll say it again: if you're developing Flash sites and not using Gaia, you're probably wasting you're time.

 Ruby on Rails Security Guide

  • September 7th, 2009
  • 10:31 pm

Just read through the Ruby on Rails Security Guide, and i Have to say there is some great info in there. I don't use RoR at all, but a lot of the info would apply to any web application.

 Senior Flash/Flex Developer available

  • August 24th, 2009
  • 12:00 pm

I've recently completed a long-term project, so I'm currently looking for some remote (off-site) freelancing projects. I am an advanced Flex/Actionscript 3 developer with about 6 years of heavy actionscript development.

Key Skills:
Flash – Actionscript 3.0, Flex, AMFPHP, Flash Media Server, AIR, Flex Builder/Eclipse, ElectroServer
Frameworks – PureMVC , Mate, Cairngorm, Gaia
Server Side – PHP, MySQL, Propel ORM, ImageMagick, Amazon EC2/S3/SQS
Other – SVN, CVS, XML, Javascript
Software design – OO design, Design Patterns

My resume can be found at http://www.f1fd.com/resume, and you can email me at f1info@f1fd.com.

 Amazon EC2 Error: ‘Has the image been rebundled but not re-registered?’

  • July 29th, 2009
  • 12:40 am

Went to launch an ec2 instance tonight and get a wierd error:

Registered machine image manifest for ami-XXXXXXXX and manifest in S3 differ. Has the image been rebundled but not re-registered?

Errr...probably :) Anyway, the solution is pretty easy: de-register the old instance and re-register the manifest.xml file in the bucket where your storing your image. Then use the new ami id to launch the instance.

 Gaia – Now that’s impressive

  • July 27th, 2009
  • 8:31 pm

I've doing a "regular" flash-based website, which I haven't done in a while since pretty much all of my work for the last year has been Flex. I've heard a lot about Gaia so I decided to implement it on this project, and I have to say, I am really impressed. There's a small learning curve, and that's just to get used to the 'Gaia flow', which basically everything revolves around individual site sections that transition and out. Once you pick that up (and that happened pretty quickly) you see the beauty of it.

The thing that I think I appreciate about Gaia so far is that it has the capability to let you do really cool, complicated stuff, but you wouldn't know it unless you needed it. Otherwise, it stays somewhere off in the distance ready to be called upon when you need it.

Oh yeah, and it takes care of deep linking and SEO for you as a bonus. Oh yeah part 2, it also throws in right-click menu site navigation, if you'd like.

If you're developing flash sites, you need to look into this. To not would be a foolish waste of your time.