0

I write a small flex project that connect to local database

the code is below:

    _dbData=new DataBaseData();
    _dbData.username="root";
    _dbData.password="woxnsk";
    _dbData.host="192.168.2.225";
    _dbData.port=3306;
    _dbData.database="query";
    _db=new MyDataBase(_dbData);
    _db.addEventListener(Event.CONNECT, onConnected);
    _db.connect();

    _isDBConnecting=true;

the project works well in flex builder,then I deployed it in my wamp server and something went wrong.

I can access the databse when I use the url like localhost/myproject/login.html but if I change the localhost into 127.0.0.1 or the ip 192.168.2.225, it failed to connect to database , and the error is Security Sandbox violation.

Error #2044: unhandled ioError: text=Error #2048: Security Sandbox violation.:http://192.168.2.225/bin-debug/QuestionCollecter.swf cannot load data from 192.168.2.225:3306

I have put the crossdomain.xml in the root directory of my server (C:\wamp\www or C:\apache-tomcat-6.0.35\webapps\ROOT) the crossdomain.xml file is :

    <xml version="1.0"?>
    <cross-domain-policy>
        <allow-access-from domain="*" to-ports="*" />
    </cross-domain-policy>

it does not work....so is there anything wrong? Can anyone help me~

vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

1

1) You can check allowScriptAccess and allowNetworking options for embedding your swf into a page:

http://livedocs.adobe.com/flex/3/html/help.html?content=wrapper_13.html

Make sure to grant unrestricted access to your swf.

2) You can extract your server address from url property of your application.

3) You can watch with Charles or HTTPAnalyzer what happens with crossdomain.xml requests from your application and if wamp makes this file avaliable for all IPs.

4) Does your database allow non-local connections?

user1875642
  • 1,303
  • 9
  • 18
  • Thanks for you advise! I found that my 843 port was occupied by another program, so i terminated it and wrote a servlet listening to 843 port ,and the problem is gone! – facebook-1396838839 Dec 24 '12 at 08:36