1 Reply Latest reply on Oct 2, 2008 6:05 AM by Newsgroup_User

    Help - Flex 3 xmlsocket connection

    hangcui
      Hi,

      I'm new to flex and I've been suffering from the problem of using xmlsocket to connect to a standalone java server. Here is my goal - we have a java server running on a machine listening to a port, say 55555. We need the flex application to connect to the java server to do some simple conversations (send a string and get back the response). All applications reside on the same machine. Here is the snippet for AS:

      Security.loadPolicyFile("xmlsocket://localhost:843");
      var xmlsock:XMLSocket = new XMLSocket();
      xmlsock.connect("localhost", 55555);
      xmlsock.addEventListener(DataEvent.DATA, onResult);
      xmlsock.send(query);
      xmlsock.send("\n");
      xmlsock.close();

      I do have a perl daemon running to send back the policy file. However, the problem is that my backend never gets anything from the flex app. The error I got is:

      rror #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security sandbox violation: http://www.mydomain.com/Flex/build/index.swf cannot load data from localhost:55555.
      at index/requestData()
      at index/___index_Button1_click()

      I even let my backend to send back the policy file if it gets "<policy-file-request/>". However, it hasn't got anything.

      I guess the problem could be either the security thing or xmlsocket connection. As for policy file, I know a lot of people have discussed it and I've tried different approaches, like using xmlsocket and http to load the policy files. All of them didn't work.

      Could anyone give me a clue what is wrong here?

      Thanks a million in advance for any help!
        • 1. Re: Help - Flex 3 xmlsocket connection
          Level 7

          "hangcui" <webforumsuser@macromedia.com> wrote in message
          news:gc1uaj$4r6$1@forums.macromedia.com...
          > Hi,
          >
          > I'm new to flex and I've been suffering from the problem of using
          > xmlsocket to
          > connect to a standalone java server. Here is my goal - we have a java
          > server
          > running on a machine listening to a port, say 55555. We need the flex
          > application to connect to the java server to do some simple conversations
          > (send
          > a string and get back the response). All applications reside on the same
          > machine. Here is the snippet for AS:
          >
          > Security.loadPolicyFile("xmlsocket://localhost:843");
          > var xmlsock:XMLSocket = new XMLSocket();
          > xmlsock.connect("localhost", 55555);
          > xmlsock.addEventListener(DataEvent.DATA, onResult);
          > xmlsock.send(query);
          > xmlsock.send("\n");
          > xmlsock.close();
          >
          > I do have a perl daemon running to send back the policy file. However, the
          > problem is that my backend never gets anything from the flex app. The
          > error I
          > got is:
          >
          > rror #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security
          > sandbox
          > violation: http://www.mydomain.com/Flex/build/index.swf cannot load data
          > from
          > localhost:55555.
          > at index/requestData()
          > at index/___index_Button1_click()
          >
          > I even let my backend to send back the policy file if it gets
          > "<policy-file-request/>". However, it hasn't got anything.
          >
          > I guess the problem could be either the security thing or xmlsocket
          > connection. As for policy file, I know a lot of people have discussed it
          > and
          > I've tried different approaches, like using xmlsocket and http to load the
          > policy files. All of them didn't work.
          >
          > Could anyone give me a clue what is wrong here?
          >
          > Thanks a million in advance for any help!

          This may or may not help http://www.gotoandlearn.com/play?id=69