4 Replies Latest reply on Apr 29, 2009 4:12 PM by ShadowReactor

    HTTP stuff works locally, but not on remote server!

    ShadowReactor

      I think I might be a tad confused about data services in Flex and how exactly HTTP requests are made via the Flex stack. Here's the skinny: I have a Flex app that access my server (which is RESTful service via Apache/Rails); everything works great while debugging and running in Flex builder: I can make XML requests to the remote server and get data back just fine.

       

      Running my exported release build from the bin-release folder works just fine when connecting to the remote server, but when the Flex app is hosted on the server itself, requests are simply ignored (server log files don't show any requests) so I'm assuming there's got to be some sort of crossdomain, sandbox, or security policy thing going on here.

       

      I'm under the impression that the Flex app is run client-side and that means that outbound connections from the client to the server come from the client's IP and aren't considered "local", right? Anyone have any hints on the whole crossdomain thing? Is there something I'm missing?

        • 1. Re: HTTP stuff works locally, but not on remote server!
          Gregory Lafrance Level 6

          Before you post to the web, try compiling with --use-network=true

           

          When testing locally that might not matter, but once you post to the web it needs to be true.

          1 person found this helpful
          • 2. Re: HTTP stuff works locally, but not on remote server!
            ShadowReactor Level 1

            Hmm.. doesn't seem to fix the problem, anything else I can try?

            • 3. Re: HTTP stuff works locally, but not on remote server!
              ATIF FAROOQ Level 3

              hi,

                 try debugging remotely and monitor result and fault events

              • 4. Re: HTTP stuff works locally, but not on remote server!
                ShadowReactor Level 1

                Finally tracked down the problem.. several hours and multiple blog-posts later. I had been using a socket-based approach for XML requests, if you're doing this too, you'll NEED TO HAVE A SOCKET SERVER LISTENING ON PORT 843 THAT CAN SERVE UP A SOCKET POLICY FILE. Correct me if I'm wrong but everything I've read seems to suggest that Adobe has not provided a way to work around this requirement. It seems like it's possible to request the socket policy file from an alternate port, but as I found out FLEX EXPECTS SOCKET POLICY FILE CONTENTS AS THE ENTIRE RESPONSE -- that means NO HEADERS! So you're out of luck if you're trying to get Apache to serve it up.

                 

                You'll need a [simple] socket server. My hacked-together solution, while insecure, works! It just routes my normal crossdomain.xml to port 843. It looks like this:

                 

                 

                #!/usr/bin/env ruby
                
                # This is a very minimal socket server designed to route a cross-domain policy
                # file hosted via a webserver (like Apache) through an alternate port.
                
                require 'socket'
                require 'net/http'
                
                LISTEN_PORT = 843
                
                server = TCPServer.open(LISTEN_PORT)
                loop {
                  Thread.start(server.accept) do |client|
                    Net::HTTP.start( 'www.someserver.com', 80 ) { |http| client.puts http.get('/crossdomain.xml').body }
                       client.close
                  end
                }
                

                 

                 

                I hope this helps someone else with the same problem!