Granite SecureAMFChannel – AMF over HTTPS
filed in Programming on Mar.15, 2009
At work we’ve started to use JBoss, writing an application in Java and AS 3.0. We’re using Seam and Tide to sandwich it all together, and we came upon a slight problem. Everything worked out great in the test environment, but when we went live, on an HTTPS connection, firebug was reporting that the AMF request out of flex was failing. That’s due to the services-config.xml in the application pointing to a non-secure connection. After much digging, we found this to be the solution.
WEB-INF/flex/services-config.xml
in the channels definition at the top:
<channels>
<!--USED IN THE LIVE ENVIRONMENT-->
<!--channel ref="my-graniteamf-secure"/-->
<!--USED IN THE LOCAL/DEV ENVIRONMENT-->
<channel ref="my-graniteamf"/>
</channels>
Then in the channel definition below we have both definitions:
<channel-definition id="my-graniteamf"
class="mx.messaging.channels.AMFChannel">
<endpoint
uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
</channel-definition>
<channel-definition id="my-graniteamf-secure"
class="mx.messaging.channels.SecureAMFChannel">
<endpoint
uri="https://{server.name}:443/{context.root}/graniteamf/amf"
class="flex.messaging.endpoints.SecureAMFEndpoint" />
</channel-definition>
We couldn’t get {server.port} to work correctly, so we’re forcing the port in the address for now.
The only problem with this is you have to remember to switch the AMF channel before deploying. It’s on our checklist before doing the full deploy, but we’re most likely going to add it to the ant task list to deploy dev, deploy live. Something like that.
The KEY THING TO REMEMBER is this: although this file is deployed with the war/ear, it is ALSO COMPILED INTO THE APPLICATION SWF when it is built. Make sure to change it locally and rebuild your swf before posting, or you will see no change in your app. (found this out after a significant amount of time changing the file on the server to no avail…)
(Ref: http://www.mail-archive.com/discussion@affug.com/msg00605.html)

October 15th, 2009 on 3:32 am
Thanks,helpful post, why do you need to SecureAMFChannel – AMF in the con-fig file , if you site already has https and you embed your swf in your site ?
October 18th, 2009 on 7:18 pm
Thanks for posting this as it will save me a lot of time having to dig around on how to implement a secure connection with granite. This is especially important right now as I’m the only programmer on my current project =]