From noted CF trainer, writer, and consultant Charlie Arehart, CFMXPLUS has been devoted to issues and ideas of value to ColdFusion and BlueDragon developers. You can find him posting new content at carehart.org/blog/

Sunday, February 09, 2003

Have you ever had a Flash Remoting movie that seems to fail, in that some expected communications from the server never is returned? And worse, that even the NetConnection Debugger shows it opening a connection and calling the service but just then getting no further response?

The problem may be caused by a conflict between the URL you're using to loading the movie and that which is being used to connect to the remoting server in your ActionScript, such as the createGatewayConnection.

If that statement indicates to make a remoting connection to serverA, but you try to load the SWF from serverB, you won't get an error, but you won't get the expected result. Instead, the debugging will show what I've referred to above.

Now, on the surface, this may be logical to experienced Flash folks who know that this is a security feature to keep code loaded from one server from being able to connect to code running on another server (of course, that IS allowed if you're using web services).

The thing is, it might happen in a way that you wouldn't immediately recognize as an obvious case of this security breach: Consider if your ActionScript code connects to the server using 127.0.0.1, but then you load the SWF (or the page containing the SWF) using a URL with localhost? In most instances, localhost and 127.0.0.1 are the same thing, but not to Flash, and therefore not when doing remoting this way. So you need to know which server the code is trying to connect to in order to get it to run (that's another challenge that I'll discuss in a later blog entry).

Here's a screenshot of the NetConnection Debugger in this example, where the code is doing:

but the swf including that code is being called with a url such as http://localhost/whatever.swf:

Notice that it shows the connect (from the createGatewayConnection) and the call (from the getService), but no further response.

More useful is to note that the image is showing that the "details" tab has been selected. Look carefully and notice that the ConnectString is referring to 127.0.0.1, but the MovieUrl says it was opened using localhost. That's the essence of the problem.

Frankly, I wish that the NetConnection Debugger would detect this fact and give us a warning. I tried to look in the .as file supporting the debugger but didn't see an immediate solution. If this is enough to trigger anyone else figuring a solution, do let me know via the "add a comment" feature below.