22 Replies Latest reply on Jun 1, 2008 11:11 AM by mirkasim

    socket connection - $30 reward

    EladElrom
      I am building an application that uses the socket connection. When the application is running from my desktop it is working fine, however when it's running on a remote server I am getting sandbox security violation: "cannot load data from serverName.com:portNumber."

      There is another application on Adobe lab (Posted by Josh Tynjala) that people have the same problem: http://www.zeuslabs.us/archives/6/connecting-to-aim-with-actionscript-3-sockets/

      Josh answer was: "You have to run the SWF from somewhere on your own computer."

      His application is running fine locally, however when I upload it to a remote server I am getting: "cannot load data from aimexpress.oscar.aol.com:5190." Is there any way to get the socket connection to work on a remote server, and not just on the desktop?

      I will give $30 (using western union or paypal) if someone can get Josh Tynjala application to work on remote server.
        • 1. Re: socket connection - $30 reward
          michael_ramirez44 Level 1
          What are you trying to connect to?

          The server you are trying to connect to must have a crossdomain.xml file defined that allows you to have access unless it is from the same domain that the swf was loaded from.
          • 2. Re: socket connection - $30 reward
            EladElrom Level 1
            It has the crossdomain.xml which is set to "*", which should allow any server connection. The application doesn't work without the crossdomain.xml.
            • 3. Re: socket connection - $30 reward
              FlightGuy Level 1
              Are you loading the .swf from http://something.aol.com? or is it being loaded from a different server (and do you need to load it from a different server?)

              Tim
              • 4. Re: socket connection - $30 reward
                FlightGuy Level 1
                You won't be able to make the AIM application work from anywhere other than the desktop because the crossdomain.xml needs to be in the AIM server (and it's not likely you'll persuade them - unless you work there - to post a crossdomain.xml file). Something I'm not sure of, and I'd be interested in hearing from someone who is, is how Flash determines the url to search for the crossdomain.xml file. Does it assume it's port 80? and would it, in and example such as this, look at http://oscar.aol.com? If so, and if you haven't done so yet, deploy your crossdomain.xml file to the root of http://oscar.aol.com.

                Tim
                • 5. Re: socket connection - $30 reward
                  EladElrom Level 1
                  I tried it both ways.

                  Putting it in the same site URL and different server both didn't worked. the swf is only working on the desktop.

                  At the end the swf file need to connect to a different server, but I just want to see it working, for now....
                  • 6. Re: socket connection - $30 reward
                    EladElrom Level 1
                    Thanks Tim.

                    I am trying to get my application to work and not the AOL AIM.

                    I used the AIM as an example so people can understand what I am talking about but I know it lack the XML file and will not work without it...

                    I did put the XML on the server with permission to let access to all servers like this:

                    <allow-access-from domain="*" to-ports="80" />

                    so it should have worked. However it only works when the application is running on the desktop.
                    • 7. Re: socket connection - $30 reward
                      FlightGuy Level 1
                      OK, I read the doc - you'll find the relevant sections on page 468 of the "Programming ActionScript 3.0" manual. You have some options about how to deliver the socket cross-domain policy file. You can deliver it from the same port (5190) by making the socket server respond to the request <policy-file-request/> by sending the contents of your crossdomain.xml file (with the to-ports="5190" property set). After doing this, end the connection - flex will establish a new connection once it's loaded the policy file.

                      Alternatively you can listen on another socket for policy requests, in which case a connection to that port can be answered immediately by sending the contents of the crossdomain.xml file. In this case, before you connect to port 5190, call:

                      Security.loadPolicyFile("xmlsocket://aimexpress.oscar.aol.com:5151");
                      // or whatever port you've chosen

                      As far as I can tell you can also use a normal HTTP delivered crossdomain.xml file, and if you're using a port above 1024 you don't need to specify the to-port property in the crossdomain.xml file. In this case it would need to be accessible as http://aimexpress.oscar.aol.com/crossdomain.xml. In this case, you will need to explicitly load the policy file as well:

                      Security.loadPolicyFile(" http://aimexpress.oscar.aol.com/crossdomain.xml");

                      I haven't tried any of this, but will need to in due course, so I would appreciate feedback if this works.

                      Tim
                      • 8. Re: socket connection - $30 reward
                        FlightGuy Level 1
                        What port number are you trying to connect to? If it's below 1024 I don't believe you can use and http served policy file, and you'll need to use one of the two socket options.

                        Tim
                        • 9. Re: socket connection - $30 reward
                          EladElrom Level 1
                          I heard about that before... the only problem is that my application is using port 80, which is the lower port and I am not sure if it will work, but I will try to make the AOL application to work and that can be a good start... I will let you know...
                          • 10. Re: socket connection - $30 reward
                            EladElrom Level 1
                            Also.. .I am actually using the "Security.loadPolicyFile" in my application and it didn't helped in any way...
                            • 11. Re: socket connection - $30 reward
                              EladElrom Level 1
                              I just tried using the:

                              import flash.system.Security;
                              Security.loadPolicyFile("xmlsocket://aimexpress.oscar.aol.com:5151");

                              on the AIM application, no luck there...
                              • 12. Re: socket connection - $30 reward
                                FlightGuy Level 1
                                My choice of 5151 in the AOL example was arbitrary - you would need to have code running on that machine to respond to the connection. You say you're using port 80 in your code, and using a socket connection - XMLSocket, or Socket?

                                If you want to make a socket connection to port 80 you can't use an HTTP-delivered crossdomain.xml file. Do you have enough freedom in your protocol to support the same-socket crossdomain service? ie. can you make your server send no response to the client until it receives data from the client, and then if the received data is <policy-file-request/> then answer with the contents of your crossdomain file?

                                As I mentioned before, unless you're free to add code to AOL's server, you cannot make the AIM example work. The whole purpose of the crossdomain file is to require the provider of the service (AOL in this case) to authorize the access, and the only way to do this is to get them to post a crossdomain file - either via http (allowing access to all ports above 1024 and nothing below), or through a socket service (allowing access to all nominated ports).

                                Can you explain a little more about what you're trying to do, what context you expect it to be used, and what your reason is for using a direct socket connection on port 80 - nothing wrong with it, just unconventional. I'm guessing you're using port 80 to avoid firewall issues (which, if you're not using http protocol does only 90% the job).

                                This would help me understand whether you'd do better to use the same-socket option or have a dedicated socketserver to handle the policy file.

                                Tim
                                • 13. Re: socket connection - $30 reward
                                  EladElrom Level 1
                                  My class waits for a handshake before requesting information, I am forced to use low port (you were right; I need to use low port for security reasons). After the handshake the two servers are exchanging information using an event manager.

                                  I prefer to use the binary connection since there is a lot of information to pass between the servers, and I know that I can do it in different ways such as soap etc.. But I really would like to get this to work.

                                  The error occurs from the handshake. I was trying both; let the server connect to itself, or connect a different server, unfortunately both cases didn't work.
                                  I am really not that concern to get AIM example to work, since I was just using it as an example. I prefer not to post my script on an open form like this. I realize that it was the wrong example since the AIM script need the XML which will not going to happened without AOL posting the xml file on their server.

                                  Tim, are you interested helping me out with this error and I am willing to pay you for consulting on hourly rate or on a fixed rate?
                                  • 14. Re: socket connection - $30 reward
                                    FlightGuy Level 1
                                    Hi - I'm not interested in consulting for this or accepting payment, but I'm happy to work with you on the forum to get it sorted out.
                                    • 15. Re: socket connection - $30 reward
                                      FlightGuy Level 1
                                      Given that you're using port 80 and are limited to use this port to get past firewalls, you really have only one option - you cannot use http to serve the policy file, since you're already using port 80 for your socket connection. You cannot use a different port to serve it, since that would defeat your firewall solution.

                                      This leaves you with only the option of serving the policy file through the same port.

                                      You say that your server script waits for a handshake before starting to communicate. Can you make your server script, upon connection, differentiate between your client-to-server handshake message and the <policy-file-request/>? If so, when you detect the <policy-file-request/>, simply reply with the following text, and then close the socket:

                                      <cross-domain-policy><allow-access-from domain="*" to-ports="80"/></cross-domain-policy>

                                      If you do this, you shouldn't even need to do anything in your flex code. The first time a client connection is requested, flash will first connect to this socket and send <policy-file-request/>. It will wait for a reply in the form of a cross-domain-policy document, and then disconnect the socket connect. Having received this (if it allows connection), flash will reconnect with your Socket or XMLSocket connection and you can then use your own protocol.

                                      If there's some script or code that you have that you feel would help explain the issues you're having, you can send me a private message and I'll have a look.

                                      Tim
                                      • 16. Re: socket connection - $30 reward
                                        EladElrom Level 1
                                        Ok, thanks.

                                        Thank god for this forum and adobe help...
                                        The closest to what I am doing is FTP connection, so I will create a very simple script and post it soon.
                                        • 17. Re: socket connection - $30 reward
                                          FlightGuy Level 1
                                          By the way using http still gives you access to a binary stream in each direction once you've established the connection. You can transfer substantial volumes of compressed binary data. I used to do this, but then the need arose to be more responsive on the client when events happen on the server. This led me away from an http polling model to a socket connection. The socket connect is great because it allows a server-side push of data. If you are going to need to send unsolicited data from the server to the client, it's a good option. However if you're just going to be transferring large volumes of data in response to a client request, you would do well to stick with http with next to no protocol overhead (unless you're sending several scores of requests per minute, in which case it becomes a bit chatty).

                                          Tim
                                          • 18. Re: socket connection - $30 reward
                                            EladElrom Level 1
                                            Hi Tim,

                                            I am embarrassed to admit :-( , however the flash movie was not pointing to the right crossdomain.xml file…It is working fine now...

                                            Thanks so much for your help, I REALLY REALLY appreciate all your responses and help yesterday.
                                            PS: Are you working for Adobe?
                                            • 19. Re: socket connection - $30 reward
                                              FlightGuy Level 1
                                              You're welcome - no I don't work for Adobe. I'm just using flex for a project and it's in my interest for Flex to be a successful product and to have a reputation as reliable and solid. I'm doing what I can,

                                              Tim
                                              • 20. Re: socket connection - $30 reward
                                                EladElrom Level 1
                                                The cross XML file was placed in the wrong place, it is now working correctly.
                                                • 21. Re: socket connection - $30 reward
                                                  Karpagarajan Level 1
                                                  Hi...

                                                  I am facing the same problem. Can you tell me the correct path for that crossdomain.xml?

                                                  thanks
                                                  • 22. Re: socket connection - $30 reward
                                                    mirkasim Level 1
                                                    Hi, go to Flash Resources , you can find a java application that can serve policy files to resolve this problem.