Archive for August, 2006

Flex app works with FireFox but not with IE when using SSL

There are multiple uses run into the issue about the same flex app works fine with FireFox, but doesn’t work with IE. So what is the difference between FireFox and IE browser when SSL is involved? Here is a list of the cause of the problem and how to resolve it:

Note:If the first request fails but refresh works, then you need to enable an IE option “Do not save encrypted pages to disc”, make sure it is selected.

1. By default the IE header is set to no-cache.
This may cause problem when your flex app is using SSL. You can change the header setting as descript in this TechNote . That will keep the data on client long enough to have the player read it.
To change the header, follow the steps here to change the setting at html level or web server level.

You also need to double check in the channel-definition in services-config.xml (see this TechNote) :

<channel-definition id=”my-secure-amf” class=”mx.messaging.channels.SecureAMFChannel”>
<endpoint uri=”https://{}:{server.port}{context.root}/flex2gateway/” class=”flex.messaging.endpoints.SecureAMFEndpoint”/>

2. self-certificate configuration
If you are using a self-certificate, or an invalid certificate, then you will not be able to access https from IE, but it works on Firefox. An easy test can explain the problem. For example, if you are using Coldfusion gateway as following: https://localhost:8700/cfusion/flex2gateway/
if you browse that URL from Firefox, it will return a blank page, without a security popup. A blank page means that gateway is working correctly.
if you access that URL from IE, you will get a security popup dialog, once you selected “yes”, then IE will return a blank page. As you can see IE is intercepting
the request. Therefore flex can’t get to it automatically. However, after you selected “yes” which means your IE browser accepted the url as trusted address, then your flex app will work fine. So it maybe okay for internal testing by manually accept the URL, but you need to have a valid certificate for your production.

3. IE limits connections per server. See the following links:
To avoid the problem, you can do it from client side or server side.
If you can control the client machine, then you can follow the suggestion in to increase the limit.
If you can’t do that, you can change endpoint to make IE think it is from different URL.
Two approach:
a). use the concept descript in this Blog
and set the endpoint in your data services like this:


b). configure in IIS to have and, and set endpoint to

4. Another cause can be a proxy server is in use. Even if you have Keep Alive set to true in IE, you can still get one-connection-per-file. The following is from an article about this topic, which inculdes how to check the proxy server.:

Keepin Alive

In most cases, Internet Explorer uses the Keep-Alive option in HTTP 1.1 so that it can reuse a connection to fetch several files. This takes advantage of a connection that has already been warmed up, saving all the connection startup overhead.

However, there is one common situation where IE is very conservative and does not use Keep-Alive; that is when a proxy server is in use. In those cases it drops back to the old one-connection-per-file mode, which can kill performance. That rule may have made sense 10 years ago when IE was new and proxy servers were flakey, but any proxy worth using today should handle Keep-Alive with no problems.

Do you know if your connection is using a proxy server? You may be surprised to find out that you are. Some security software uses proxies to filter Web pages, for example. To see if your connection is using a proxy, start IE and click Tools, Internet Options, Connections. Click the LAN Settings button and see if the Use A Proxy Server box is checked.

Here is how to check your HTTP 1.1 settings: In IE, click Tools, Internet Options, and the Advanced tab. Scroll down to Connection and make sure that both of these boxes are checked: Use HTTP 1.1 and Use HTTP 1.1 Through Proxy Servers.

How to access database from flex 2

We often hear people asking about how to config datasource in flex to connect to a database. It is a miss conception to think that you need to config a datasource in flex and can use that datasource to connect to a database. Then how does flex app access data from a database? Flex does not connect to DB directly, but thru Java or other means. The doc has all the details regarding this topic, and has a sample of using PHP. But it may not be clear for people who are not familiar with J2EE to connect using java. Here is the steps to create access to database using Java.

Basically, there are three steps you need to accomplish in order to communicating with database from flex.

1. Write java code to communicate to the database. We usually call this an Assembler. In here, you provide the information about what database and jdbc driver you are connecting to, and create a connection to it.

2. Then config a destination which point to the Assembler in data-management.xml. Any flex app uses this destination will use this Assembler, and connecting to the same database.

3. In your flex code, you reference the data service like this:
dsEmployee = new DataService(“”);
here is a destination defined in step 2.

Now, Let us look at the sample code included in the samples.war to see how it is done. Let us look at the crm sample in dataservice.

1. Open dataservice\crm\companyapp.mxml, In there you can see the following code:

dsCompany = new DataService(“”);
// if hibernate is used, change the destination of the data service
// dsCompany = new DataService(“”);
dsCompany.addEventListener(ResultEvent.RESULT, companyResultHandler);
dsCompany.addEventListener(FaultEvent.FAULT, faultHandler);
dsCompany.addEventListener(DataConflictEvent.CONFLICT, conflictHandler);
dsCompany.autoCommit = false;

Here we are using a dataService named “” for our app.

2. Open WEF-INF\flex\data-management.xml, we can see is defined as:

<destination id=”;”>
<adapter ref=”java-dao” />

This destination point to java class amples.crm.CompanyAssembler. This is our Assembler.

3. Let us see how the Assembler is constructed.
— go to WEB-INF\src\samples\crm\, we can see :
CompanyDAO dao = new CompanyDAO(); //using CompanyDAO class
— go to, we can see
c = ConnectionHelper.getConnection(); //using ConnectionHelper class
— go to, we can see the code to connect to database:

private ConnectionHelper()
// Obtain a path to WEB-INF/classes/samples/crm
String str = URLDecoder.decode(getClass().getClassLoader().getResource(“samples/crm”).toString(),”UTF-8″);
// Create HSQLDB JDBC URL pointing to WEB-INF/db/crm/crm (where the last crm is the datanase name)
url = “jdbc:hsqldb:” + str.substring(0, str.indexOf(“classes/samples/crm”)) + “db/crm/crm”;
catch (Exception e)

This is the core of the Assembler. This is where you tell flex which database to connect.

The most important information you need to provide are the driver name and the URL. Each database has different driver name and URL, you have to make sure you are using the correct name and format. Here is a list of driver name and example of URL:



#Sybase Enterprise

#Sybase Anywhere


#url please see